Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
StakedDinero
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; import {Ownable2StepUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol"; import {ERC20Upgradeable} from "openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol"; import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol"; import {DataTypes} from "./libraries/DataTypes.sol"; import {Errors} from "./libraries/Errors.sol"; /** * @title StakedDinero * @notice Single sided staking vault for DINERO, with soft-lock mechanisms for both deposits and redemptions. * @dev Locks deposit for a short period of time which prevents token transfers. Also has a cooldown period on redemption, applied after shares are burned, with the user able to complete redemption and claim the underlying assets after the cooldown period. * @author dinero.protocol */ contract StakedDinero is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable, ERC20Upgradeable { /** * @dev Library: IERC20 - Provides safe transfer functions for IERC20. */ using SafeERC20 for IERC20; /** * @dev Library: FixedPointMathLib - Provides fixed-point arithmetic for uint256. */ using FixedPointMathLib for uint256; // Storage /// @custom:storage-location erc7201:dinero.storage.StakedDinero struct StakedDineroStorage { /** * @notice Reference to the underlying asset token contract. */ IERC20 asset; /** * @notice Reference to the migrator address. */ address migrator; /** * @notice Reference to the distributor address. */ address distributor; /** * @notice Timestamp when the current rewards period will end. */ uint256 periodFinish; /** * @notice Rate at which rewards are distributed per second. */ uint256 rewardRate; /** * @notice Timestamp of the last update to the reward variables. */ uint256 lastUpdateTime; /** * @notice Accumulated reward per token stored. */ uint256 rewardPerTokenStored; /** * @notice Last calculated reward per token paid to stakers. */ uint256 rewardPerTokenPaid; /** * @notice Total rewards available for distribution. */ uint256 rewards; /** * @notice Total assets actively staked in the vault. */ uint256 totalStaked; /** * @notice Total assets under pending redemptions. */ uint256 pendingRedemptions; /** * @notice Duration of the deposit lock. */ uint256 depositLockDuration; /** * @notice Duration of the redemption lock. */ uint256 redemptionLockDuration; /** * @notice Tracks the expiry of each user's deposit lock. */ mapping(address => uint256) depositLockExpiryTime; /** * @notice Tracks each user's pending redemption queue. */ mapping(address => DataTypes.PendingRedemptionQueue) pendingRedemptionQueue; } // keccak256(abi.encode(uint256(keccak256("dinero.storage.StakedDinero")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant StakedDineroStorageLocation = 0x189a25aed4a452a71e1e9aad4732cfcb1958b751d26283c9b5ff3524600e4100; /** * @notice Get the contract storage instance. * @dev Used to access StakedDineroStorage. * @return $ StakedDineroStorage Storage. */ function _getStakedDineroStorage() private pure returns (StakedDineroStorage storage $) { assembly { $.slot := StakedDineroStorageLocation } } // Constants /** * @dev Duration of the rewards (streaming) period. */ uint256 private constant REWARDS_DURATION = 7 days; // Events /** * @notice Emitted on deposits. * @dev This event is emitted when a user triggers the deposit function. * @param sender address indexed Address that performed the deposit. * @param receiver address indexed Address of the deposit receiver. * @param assets uint256 Assets amount. * @param shares uint256 Shares amount. */ event Deposit( address indexed sender, address indexed receiver, uint256 assets, uint256 shares ); /** * @notice Emitted on initiating redemptions. * @dev This event is emitted when a user triggers the initiateRedemption function. * @param sender address indexed Address of the shares owner. * @param assets uint256 Assets amount. * @param shares uint256 Shares amount. */ event InitiateRedemption( address indexed sender, uint256 assets, uint256 shares ); /** * @notice Emitted on completing redemptions. * @dev This event is emitted when a user triggers the redeem function. * @param sender address indexed Address of the shares owner. * @param receiver address indexed Address of the receiver. * @param assets uint256 Assets amount. */ event Redeem( address indexed sender, address indexed receiver, uint256 assets ); /** * @notice Emitted when rewards are harvested and staked. * @dev This event is emitted when the harvest function is triggered. * @param caller address indexed Address that triggered the harvest. * @param value uint256 Amount of rewards harvested. */ event Harvest(address indexed caller, uint256 value); /** * @notice Emitted when new rewards are added to the vault. * @dev This event is emitted when new rewards are added to the vault. * @param reward uint256 Amount of rewards added. */ event RewardAdded(uint256 reward); /** * @notice Emitted when the migrator address is set. * @dev This event is emitted when the migrator address is set. * @param migrator address New migrator address. */ event SetMigrator(address migrator); /** * @notice Emitted when the distributor address is set. * @dev This event is emitted when the distributor address is set. * @param distributor address New distributor address. */ event SetDistributor(address distributor); /** * @notice Emitted when the deposit lock duration is set. * @dev This event is emitted when the deposit lock duration is set. * @param depositLockDuration address New duration. */ event SetDepositLockDuration(uint256 depositLockDuration); /** * @notice Emitted when the redemption lock duration is set. * @dev This event is emitted when the redemption lock duration is set. * @param redemptionLockDuration address New duration. */ event SetRedemptionLockDuration(uint256 redemptionLockDuration); // Modifiers /** * @dev Update reward states modifier. * @param updateEarned bool Whether to update earned amount so far. */ modifier updateReward(bool updateEarned) { StakedDineroStorage storage $ = _getStakedDineroStorage(); $.rewardPerTokenStored = rewardPerToken(); $.lastUpdateTime = lastTimeRewardApplicable(); if (updateEarned) { $.rewards = earned(); $.rewardPerTokenPaid = $.rewardPerTokenStored; } _; } /** * @dev Check account's deposit lock. * @param account address Account. */ modifier checkDepositLock(address account) { // Check the expiry time of the deposit lock if (depositLockExpiryTime(account) > block.timestamp) revert Errors.Locked(); _; } constructor() { _disableInitializers(); } /** * @notice Initialize the contract with the provided parameters. * @dev This function must be called only once during contract deployment. * @param _asset IERC20 The address of the ERC20 asset token. * @param _initialOwner address The address that will initially own the contract. */ function initialize( IERC20 _asset, address _initialOwner ) external initializer { if (address(_asset) == address(0)) revert Errors.ZeroAddress(); // Setup all parent contracts init calls __Ownable_init(_initialOwner); __ReentrancyGuard_init(); __ERC20_init("Staked Dinero", "sDINERO"); StakedDineroStorage storage $ = _getStakedDineroStorage(); $.asset = _asset; $.depositLockDuration = 1 weeks; $.redemptionLockDuration = 1 weeks; $.distributor = _initialOwner; } /*////////////////////////////////////////////////////////////// RESTRICTED FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice Set the migrator address. * @dev Function access restricted to only owner. * @param _migrator address Migrator address. */ function setMigrator(address _migrator) external onlyOwner { if (_migrator == address(0)) revert Errors.ZeroAddress(); emit SetMigrator(_migrator); StakedDineroStorage storage $ = _getStakedDineroStorage(); $.migrator = _migrator; } /** * @notice Set the distributor address. * @dev Function access restricted to only owner. * @param _distributor address Distributor address. */ function setDistributor(address _distributor) external onlyOwner { if (_distributor == address(0)) revert Errors.ZeroAddress(); emit SetDistributor(_distributor); StakedDineroStorage storage $ = _getStakedDineroStorage(); $.distributor = _distributor; } /** * @notice Set the deposit lock duration. * @dev Function access restricted to only owner. * @param _depositLockDuration uint256 Duration. */ function setDepositLockDuration( uint256 _depositLockDuration ) external onlyOwner { if (_depositLockDuration == 0) revert Errors.ZeroAmount(); emit SetDepositLockDuration(_depositLockDuration); StakedDineroStorage storage $ = _getStakedDineroStorage(); $.depositLockDuration = _depositLockDuration; } /** * @notice Set the redemption lock duration. * @dev Function access restricted to only owner. * @param _redemptionLockDuration uint256 Duration. */ function setRedemptionLockDuration( uint256 _redemptionLockDuration ) external onlyOwner { StakedDineroStorage storage $ = _getStakedDineroStorage(); if ( _redemptionLockDuration == 0 || _redemptionLockDuration <= $.redemptionLockDuration ) revert Errors.InvalidDuration(); emit SetRedemptionLockDuration(_redemptionLockDuration); $.redemptionLockDuration = _redemptionLockDuration; } /** * @notice Notify and sync the newly added rewards to be streamed over time. * @dev Rewards are streamed following the duration set in REWARDS_DURATION. */ function notifyRewardAmount() external updateReward(false) { StakedDineroStorage storage $ = _getStakedDineroStorage(); if (msg.sender != $.distributor) revert Errors.Unauthorized(); // Rewards transferred directly to this contract are not added to totalStaked // To get the rewards w/o relying on a potentially incorrect passed in arg, // we can use the difference between the asset balance and totalStaked + pendingRedemptions // Additionally, to avoid re-distributing rewards, deduct the output of `earned` uint256 rewardBalance = $.asset.balanceOf(address(this)) - $.pendingRedemptions - $.totalStaked - earned(); uint256 rate = rewardBalance / REWARDS_DURATION; if (rate == 0) revert Errors.NoRewards(); $.rewardRate = rate; $.lastUpdateTime = block.timestamp; $.periodFinish = block.timestamp + REWARDS_DURATION; emit RewardAdded(rewardBalance); } /*////////////////////////////////////////////////////////////// VIEWS //////////////////////////////////////////////////////////////*/ /** * @notice Returns the asset token contract. * @return IERC20 Asset token contract. */ function asset() external view returns (IERC20) { return _getStakedDineroStorage().asset; } /** * @notice Returns the migrator address. * @return address Migrator address. */ function migrator() external view returns (address) { return _getStakedDineroStorage().migrator; } /** * @notice Returns the distributor address. * @return address Distributor address. */ function distributor() external view returns (address) { return _getStakedDineroStorage().distributor; } /** * @notice Return the total amount of staked assets. * @return uint256 Assets. */ function totalStaked() external view returns (uint256) { return _getStakedDineroStorage().totalStaked; } /** * @notice Returns the reward rate. * @return uint256 Reward rate. */ function rewardRate() external view returns (uint256) { return _getStakedDineroStorage().rewardRate; } /** * @notice Returns the last reward update time. * @return uint256 Last update time. */ function lastUpdateTime() external view returns (uint256) { return _getStakedDineroStorage().lastUpdateTime; } /** * @notice Returns the timestamp when the current rewards period will end. * @return uint256 Reward period ending time. */ function periodFinish() public view returns (uint256) { return _getStakedDineroStorage().periodFinish; } /** * @notice Returns the accumulated reward per token stored. * @return uint256 Reward per token stored. */ function rewardPerTokenStored() external view returns (uint256) { return _getStakedDineroStorage().rewardPerTokenStored; } /** * @notice Returns the last calculated reward per token paid to stakers. * @return uint256 Reward per token paid. */ function rewardPerTokenPaid() external view returns (uint256) { return _getStakedDineroStorage().rewardPerTokenPaid; } /** * @notice Returns the total rewards available for distribution. * @return uint256 Rewards. */ function rewards() external view returns (uint256) { return _getStakedDineroStorage().rewards; } /** * @notice Return the duration of the deposit lock period. * @return uint256 Deposit lock duration. */ function depositLockDuration() external view returns (uint256) { return _getStakedDineroStorage().depositLockDuration; } /** * @notice Return the duration of the redemption lock period. * @return uint256 Redemption lock duration. */ function redemptionLockDuration() external view returns (uint256) { return _getStakedDineroStorage().redemptionLockDuration; } /** * @notice Returns the expiry of the account's deposit lock. * @param account address Account address. * @return uint256 Lock expiry time. */ function depositLockExpiryTime( address account ) public view returns (uint256) { return _getStakedDineroStorage().depositLockExpiryTime[account]; } /** * @notice Returns the list of pending (both redeemable and future) redemptions of the account. * @param account address Account address. * @return redemptionList PendingRedemption[] List of pending redemption records. */ function pendingRedemptionList( address account ) external view returns (DataTypes.PendingRedemption[] memory redemptionList) { StakedDineroStorage storage $ = _getStakedDineroStorage(); DataTypes.PendingRedemptionQueue memory queue = $ .pendingRedemptionQueue[account]; uint256 count = queue.redeemedCount; DataTypes.PendingRedemption[] memory redemptions = queue .pendingRedemptions; uint256 queueLen = redemptions.length; redemptionList = new DataTypes.PendingRedemption[](queueLen - count); uint256 idx = 0; // Skip redeemed records for (uint256 i = count; i < queueLen; ) { DataTypes.PendingRedemption memory record = redemptions[i]; redemptionList[idx] = record; unchecked { ++i; ++idx; } } return redemptionList; } /** * @notice Returns the last effective timestamp of the current reward period. * @return uint256 Last applicable timestamp. */ function lastTimeRewardApplicable() public view returns (uint256) { uint256 _periodFinish = periodFinish(); return block.timestamp < _periodFinish ? block.timestamp : _periodFinish; } /** * @notice Returns the total amount of pending redemptions. * @return uint256 Total amount of pending redemptions. */ function pendingRedemptions() external view returns (uint256) { return _getStakedDineroStorage().pendingRedemptions; } /** * @notice Returns the amount of rewards per staked token/asset. * @return uint256 Rewards amount. */ function rewardPerToken() public view returns (uint256) { StakedDineroStorage storage $ = _getStakedDineroStorage(); uint256 _totalStaked = $.totalStaked; if (_totalStaked == 0) { return $.rewardPerTokenStored; } return $.rewardPerTokenStored + ((((lastTimeRewardApplicable() - $.lastUpdateTime) * $.rewardRate) * 1e18) / _totalStaked); } /** * @notice Returns the earned rewards amount so far. * @return uint256 Rewards amount. */ function earned() public view returns (uint256) { StakedDineroStorage storage $ = _getStakedDineroStorage(); return (($.totalStaked * (rewardPerToken() - $.rewardPerTokenPaid)) / 1e18) + $.rewards; } /** * @notice Returns the estimated shares amount on deposit. * @return uint256 Shares amount. */ function previewDeposit(uint256 assets) public view returns (uint256) { uint256 supply = totalSupply(); return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets()); } /** * @notice Returns the estimated assets amount on initiateRedemption. * @return uint256 Assets amount. */ function previewInitiateRedemption( uint256 shares ) public view returns (uint256) { uint256 supply = totalSupply(); return supply == 0 ? 0 : shares.mulDivDown(totalAssets(), supply); } /** * @notice Return the amount of assets per 1 (1e18) share. * @return uint256 Assets. */ function assetsPerShare() external view returns (uint256) { return previewInitiateRedemption(1e18); } /** * @notice Get the amount of available DINERO in the contract. * @dev Rewards are streamed for the duration set in REWARDS_DURATION. * @return uint256 Total assets including accrued rewards. */ function totalAssets() public view returns (uint256) { StakedDineroStorage storage $ = _getStakedDineroStorage(); // Based on the current totalStaked and available rewards uint256 _totalStaked = $.totalStaked; uint256 _rewards = ((_totalStaked * (rewardPerToken() - $.rewardPerTokenPaid)) / 1e18) + $.rewards; return _totalStaked + _rewards; } /*////////////////////////////////////////////////////////////// INTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @dev Internal method to keep track of the total amount of staked token/asset on deposits. * @param amount uint256 Amount. */ function _stake(uint256 amount) internal updateReward(true) { StakedDineroStorage storage $ = _getStakedDineroStorage(); $.totalStaked += amount; } /*////////////////////////////////////////////////////////////// ERC20Upgradeable OVERRIDES //////////////////////////////////////////////////////////////*/ /** * @inheritdoc ERC20Upgradeable * @notice Override transfer logic. * @dev This function overrides the standard transfer logic to check for deposit lock. * @param to address Transfer destination. * @param amount uint256 Amount. * @return bool Transfer success status. */ function transfer( address to, uint256 amount ) public override(ERC20Upgradeable) checkDepositLock(msg.sender) returns (bool) { return super.transfer(to, amount); } /** * @inheritdoc ERC20Upgradeable * @notice Override transferFrom logic. * @dev This function overrides the standard transferFrom logic to check for deposit lock. * @param from address Address of the transfer origin. * @param to address Address of the transfer destination. * @param amount uint256 Amount of tokens to transfer. * @return bool Transfer success status. */ function transferFrom( address from, address to, uint256 amount ) public override(ERC20Upgradeable) checkDepositLock(from) returns (bool) { return super.transferFrom(from, to, amount); } /*////////////////////////////////////////////////////////////// MUTATIVE FUNCTIONS //////////////////////////////////////////////////////////////*/ /** * @notice Handle user deposits in DINERO. * @dev This function processes user deposits in DINERO and mint sDINERO shares in return. * @param assets uint256 Assets amount. * @param receiver address Address of the deposit receiver. * @return uint256 Shares amount. */ function deposit( uint256 assets, address receiver ) external nonReentrant returns (uint256) { StakedDineroStorage storage $ = _getStakedDineroStorage(); // Note, receiver defaults to the caller, unless the caller is the migrator address sender = msg.sender; address sharesReceiver = (sender == $.migrator ? receiver : sender); uint256 shares = previewDeposit(assets); if (shares == 0) revert Errors.ZeroAmount(); if (sharesReceiver == address(0)) revert Errors.ZeroAddress(); // Refresh the timer for last deposit tracking // Note that it applies to all shares of the user including from previous deposits $.depositLockExpiryTime[sharesReceiver] = block.timestamp + $.depositLockDuration; emit Deposit(sender, sharesReceiver, assets, shares); $.asset.safeTransferFrom(sender, address(this), assets); // Mint shares and stake the new assets _mint(sharesReceiver, shares); _stake(assets); return shares; } /** * @notice Initiate redemption by burning sDINERO shares and then queue up a pending redemption record. * @dev This function starts the redemption process for the users. * @param shares uint256 Shares amount. * @return uint256 Pending assets amount. */ function initiateRedemption( uint256 shares ) external checkDepositLock(msg.sender) returns (uint256) { uint256 assets = previewInitiateRedemption(shares); if (assets == 0) revert Errors.ZeroAmount(); StakedDineroStorage storage $ = _getStakedDineroStorage(); // Perform harvest to make sure that totalStaked is always equal or larger than assets to be withdrawn if (assets > $.totalStaked) harvest(); $.totalStaked -= assets; // Make sure these assets are marked as part of pending redemptions $.pendingRedemptions += assets; _burn(msg.sender, shares); // Add a new pending redemption record for the user to the queue DataTypes.PendingRedemptionQueue storage queue = $ .pendingRedemptionQueue[msg.sender]; DataTypes.PendingRedemption memory redemption; redemption.activeTime = block.timestamp + $.redemptionLockDuration; redemption.amount = assets; queue.pendingRedemptions.push(redemption); emit InitiateRedemption(msg.sender, assets, shares); return assets; } /** * @notice Complete eligible redemptions after the designated active time and perform the assets transfer. * @dev This function completes the redemption process for the users on all eligible pending redemptions. * @param receiver address Address of the receiver. * @param maxCount uint256 Max number of pending records to be processed (0 for no limit). * @return uint256 Assets amount. */ function redeem( address receiver, uint256 maxCount ) external nonReentrant returns (uint256) { if (receiver == address(0)) revert Errors.ZeroAddress(); StakedDineroStorage storage $ = _getStakedDineroStorage(); DataTypes.PendingRedemptionQueue storage queue = $ .pendingRedemptionQueue[msg.sender]; uint256 count = queue.redeemedCount; DataTypes.PendingRedemption[] storage redemptions = queue .pendingRedemptions; uint256 queueLen = redemptions.length; if (count == queueLen) revert Errors.ZeroAmount(); uint256 redeemAmount = 0; uint256 currentTime = block.timestamp; uint256 limit = maxCount > 0 ? maxCount : queueLen; // Skip redeemed records and check for eligible pending redemptions // based on the expiry of the redemption lock. // Note that the method processes all eligible/unlocked redemptions within the limit for (uint256 i = count; i < queueLen; ++i) { DataTypes.PendingRedemption memory record = redemptions[i]; if (record.activeTime <= currentTime && limit > 0) { redeemAmount += record.amount; ++count; --limit; } else { // Can safely break here since subsequent records will have further expiry time // or if we hit the max number of processed records break; } } if (redeemAmount == 0) revert Errors.ZeroAmount(); emit Redeem(msg.sender, receiver, redeemAmount); // Update the redeemed record count and perform assets transfer queue.redeemedCount = count; $.pendingRedemptions -= redeemAmount; $.asset.safeTransfer(receiver, redeemAmount); return redeemAmount; } /** * @notice Harvest and stake available rewards. * @dev This function claims and stakes the available rewards. */ function harvest() public updateReward(true) { StakedDineroStorage storage $ = _getStakedDineroStorage(); uint256 _rewards = $.rewards; if (_rewards != 0) { $.rewards = 0; _stake(_rewards); emit Harvest(msg.sender, _rewards); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {OwnableUpgradeable} from "./OwnableUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step struct Ownable2StepStorage { address _pendingOwner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00; function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) { assembly { $.slot := Ownable2StepStorageLocation } } event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); function __Ownable2Step_init() internal onlyInitializing { } function __Ownable2Step_init_unchained() internal onlyInitializing { } /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); return $._pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); $._pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { Ownable2StepStorage storage $ = _getOwnable2StepStorage(); delete $._pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // 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; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._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 { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant MAX_UINT256 = 2**256 - 1; uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y)) if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) { revert(0, 0) } // Divide x * y by the denominator. z := div(mul(x, y), denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y)) if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) { revert(0, 0) } // If x * y modulo the denominator is strictly greater than 0, // 1 is added to round up the division of x * y by the denominator. z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { let y := x // We start y at x, which will help us make our initial estimate. z := 181 // The "correct" value is 1, but this saves a multiplication later. // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically. // We check y >= 2^(k + 8) but shift right by k bits // each branch to ensure that if x >= 256, then y >= 256. if iszero(lt(y, 0x10000000000000000000000000000000000)) { y := shr(128, y) z := shl(64, z) } if iszero(lt(y, 0x1000000000000000000)) { y := shr(64, y) z := shl(32, z) } if iszero(lt(y, 0x10000000000)) { y := shr(32, y) z := shl(16, z) } if iszero(lt(y, 0x1000000)) { y := shr(16, y) z := shl(8, z) } // Goal was to get z*z*y within a small factor of x. More iterations could // get y in a tighter range. Currently, we will have y in [256, 256*2^16). // We ensured y >= 256 so that the relative difference between y and y+1 is small. // That's not possible if x < 256 but we can just verify those cases exhaustively. // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256. // Correctness can be checked exhaustively for x < 256, so we assume y >= 256. // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps. // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256. // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18. // There is no overflow risk here since y < 2^136 after the first branch above. z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181. // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // If x+1 is a perfect square, the Babylonian method cycles between // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor. // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case. // If you don't care whether the floor or ceil square root is returned, you can remove this statement. z := sub(z, lt(div(x, z), z)) } } function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Mod x by y. Note this will return // 0 instead of reverting if y is zero. z := mod(x, y) } } function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) { /// @solidity memory-safe-assembly assembly { // Divide x by y. Note this will return // 0 instead of reverting if y is zero. r := div(x, y) } } function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Add 1 to x * y if x % y > 0. Note this will // return 0 instead of reverting if y is zero. z := add(gt(mod(x, y), 0), div(x, y)) } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; /** * @title DataTypes * @notice Library containing various commonly used data structures. * @author dinero.protocol */ library DataTypes { // Used for storing individual pending redemption record. struct PendingRedemption { /** * @notice Reference to the active timestamp of the redemption. */ uint256 activeTime; /** * @notice Reference to the assets amount. */ uint256 amount; } // Used for storing pending redemption queue struct PendingRedemptionQueue { /** * @notice Reference to the number of redeemed records. */ uint256 redeemedCount; /** * @notice Reference to the list of pending redemption records. */ PendingRedemption[] pendingRedemptions; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; /** * @title Errors * @notice Library containing various commonly used error definitions. * @author dinero.protocol */ library Errors { /** * @dev Zero address specified. */ error ZeroAddress(); /** * @dev Zero amount specified. */ error ZeroAmount(); /** * @dev Empty string. */ error EmptyString(); /** * @dev Unauthorized access. */ error Unauthorized(); /** * @dev Locked. */ error Locked(); /** * @dev No rewards available. */ error NoRewards(); /** * @dev Mismatched array lengths. */ error MismatchedArrayLengths(); /** * @dev Empty array. */ error EmptyArray(); /** * @dev Invalid epoch. */ error InvalidEpoch(); /** * @dev Insufficient balance. */ error InsufficientBalance(); /** * @dev Already redeemed. */ error AlreadyRedeemed(); /** * @dev Invalid duration. */ error InvalidDuration(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ 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 (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/", "solmate/=lib/solmate/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/", "solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidDuration","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"Locked","type":"error"},{"inputs":[],"name":"NoRewards","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"InitiateRedemption","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"depositLockDuration","type":"uint256"}],"name":"SetDepositLockDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"distributor","type":"address"}],"name":"SetDistributor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"migrator","type":"address"}],"name":"SetMigrator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"redemptionLockDuration","type":"uint256"}],"name":"SetRedemptionLockDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetsPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositLockDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"depositLockExpiryTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_asset","type":"address"},{"internalType":"address","name":"_initialOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"initiateRedemption","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"pendingRedemptionList","outputs":[{"components":[{"internalType":"uint256","name":"activeTime","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct DataTypes.PendingRedemption[]","name":"redemptionList","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingRedemptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewInitiateRedemption","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"maxCount","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redemptionLockDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositLockDuration","type":"uint256"}],"name":"setDepositLockDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_distributor","type":"address"}],"name":"setDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_migrator","type":"address"}],"name":"setMigrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_redemptionLockDuration","type":"uint256"}],"name":"setRedemptionLockDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052348015600e575f80fd5b5060156019565b60c9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161560685760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b039081161460c65780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6124af806100d65f395ff3fe608060405234801561000f575f80fd5b5060043610610281575f3560e01c806379ba509711610156578063bfe10928116100ca578063e1f2030211610084578063e1f20302146104fd578063e30c397814610510578063ebe2b12b14610518578063ef8b30f714610520578063f2fde38b14610533578063fe5be48114610546575f80fd5b8063bfe10928146104c2578063c8f33c91146104ca578063cd3daf9d146104d2578063d6f19262146104da578063dd62ed3e146104e2578063df136d65146104f5575f80fd5b80638da5cb5b1161011b5780638da5cb5b1461047c57806395d89b41146104845780639ec5a8941461048c578063a43b4ed114610494578063a8024b06146104a7578063a9059cbb146104af575f80fd5b806379ba5097146104545780637b0a47ee1461045c5780637cd07e471461046457806380faa57d1461046c578063817b1cd214610474575f80fd5b806335d16e17116101f8578063485cc955116101b2578063485cc955146103d757806367970cba146103ea5780636e553f65146103f257806370a0823114610405578063715018a61461043957806375619ab514610441575f80fd5b806335d16e171461038457806338d52e0f1461038c5780633ab15478146103ac5780633de6d3ee146103b4578063424c79ca146103c75780634641257d146103cf575f80fd5b80631e9a6950116102495780631e9a69501461030957806323b872dd1461031c57806323cf31181461032f5780632b71c8e414610342578063313ce5671461035557806335384aff14610364575f80fd5b806301e1d1141461028557806306fdde03146102a0578063095ea7b3146102b55780630c51dde4146102d857806318160ddd146102e2575b5f80fd5b61028d610559565b6040519081526020015b60405180910390f35b6102a86105c5565b6040516102979190612065565b6102c86102c33660046120ab565b610685565b6040519015158152602001610297565b6102e061069e565b005b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461028d565b61028d6103173660046120ab565b610842565b6102c861032a3660046120d5565b610a1d565b6102e061033d366004612113565b610a5c565b6102e061035036600461212e565b610af5565b60405160128152602001610297565b610377610372366004612113565b610b63565b6040516102979190612145565b61028d610cee565b610394610d05565b6040516001600160a01b039091168152602001610297565b61028d610d1d565b61028d6103c2366004612113565b610d2f565b61028d610d59565b6102e0610d6b565b6102e06103e5366004612193565b610e12565b61028d610fe8565b61028d6104003660046121ca565b610ffa565b61028d610413366004612113565b6001600160a01b03165f9081525f8051602061243a833981519152602052604090205490565b6102e0611136565b6102e061044f366004612113565b611149565b6102e06111e2565b61028d61122f565b610394611241565b61028d61125c565b61028d61127d565b61039461128f565b6102a86112c3565b61028d611301565b61028d6104a236600461212e565b611313565b61028d611366565b6102c86104bd3660046120ab565b611378565b6103946113b5565b61028d6113d0565b61028d6113e2565b61028d61145f565b61028d6104f0366004612193565b6114b3565b61028d6114fc565b6102e061050b36600461212e565b61150e565b610394611589565b61028d6115b1565b61028d61052e36600461212e565b6115c3565b6102e0610541366004612113565b611610565b61028d61055436600461212e565b611695565b5f806105636117f2565b90505f816009015490505f8260080154670de0b6b3a764000084600701546105896113e2565b6105939190612201565b61059d9085612214565b6105a7919061222b565b6105b1919061224a565b90506105bd818361224a565b935050505090565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0380546060915f8051602061243a833981519152916106039061225d565b80601f016020809104026020016040519081016040528092919081815260200182805461062f9061225d565b801561067a5780601f106106515761010080835404028352916020019161067a565b820191905f5260205f20905b81548152906001019060200180831161065d57829003601f168201915b505050505091505090565b5f33610692818585611816565b60019150505b92915050565b5f806106a86117f2565b90506106b26113e2565b60068201556106bf61125c565b600582015581156106e2576106d261145f565b6008820155600681015460078201555b5f6106eb6117f2565b60028101549091506001600160a01b0316331461071a576040516282b42960e81b815260040160405180910390fd5b5f61072361145f565b6009830154600a84015484546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610772573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610796919061228f565b6107a09190612201565b6107aa9190612201565b6107b49190612201565b90505f6107c462093a808361222b565b9050805f036107e657604051630fec21fd60e21b815260040160405180910390fd5b6004830181905542600584018190556108039062093a809061224a565b60038401556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050505050565b5f61084b611828565b6001600160a01b0383166108725760405163d92e233d60e01b815260040160405180910390fd5b5f61087b6117f2565b335f908152600e820160205260409020805460018201805493945091929091908083036108bb57604051631f2a200560e01b815260040160405180910390fd5b5f4281896108c957836108cb565b895b9050855b84811015610968575f8682815481106108ea576108ea6122a6565b905f5260205f2090600202016040518060400160405290815f8201548152602001600182015481525050905083815f01511115801561092857505f83115b1561095957602081015161093c908661224a565b9450610947886122ba565b9750610952836122d2565b925061095f565b50610968565b506001016108cf565b50825f0361098957604051631f2a200560e01b815260040160405180910390fd5b6040518381526001600160a01b038c169033907fd12200efa34901b99367694174c3b0d32c99585fdf37c7c26892136ddd0836d99060200160405180910390a3858755600a880180548491905f906109e2908490612201565b909155505087546109fd906001600160a01b03168c8561185f565b5090965050505050505061069860015f8051602061245a83398151915255565b5f8342610a2982610d2f565b1115610a48576040516303cb96db60e21b815260040160405180910390fd5b610a538585856118d1565b95945050505050565b610a646118f4565b6001600160a01b038116610a8b5760405163d92e233d60e01b815260040160405180910390fd5b6040516001600160a01b03821681527ff40543f3e605deae7fbca26db18ff1de07eda2925d68655836eae4c167444e329060200160405180910390a15f610ad06117f2565b60010180546001600160a01b0319166001600160a01b03939093169290921790915550565b610afd6118f4565b805f03610b1d57604051631f2a200560e01b815260040160405180910390fd5b6040518181527f8fe4a0bc6b45606382245a54a20e81f06b78455da7130159a8f7229d060987df9060200160405180910390a15f610b596117f2565b600b019190915550565b60605f610b6e6117f2565b90505f81600e015f856001600160a01b03166001600160a01b031681526020019081526020015f206040518060400160405290815f820154815260200160018201805480602002602001604051908101604052809291908181526020015f905b82821015610c11578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190610bce565b505050915250508051602082015180519293509091610c308382612201565b67ffffffffffffffff811115610c4857610c486122e7565b604051908082528060200260200182016040528015610c8c57816020015b604080518082019091525f8082526020820152815260200190600190039081610c665790505b5095505f835b82811015610ce2575f848281518110610cad57610cad6122a6565b6020026020010151905080898481518110610cca57610cca6122a6565b60209081029190910101525060019182019101610c92565b50505050505050919050565b5f610d00670de0b6b3a7640000611313565b905090565b5f610d0e6117f2565b546001600160a01b0316919050565b5f610d266117f2565b600a0154905090565b5f610d386117f2565b6001600160a01b039092165f908152600d9290920160205250604090205490565b5f610d626117f2565b600b0154905090565b60015f610d766117f2565b9050610d806113e2565b6006820155610d8d61125c565b60058201558115610db057610da061145f565b6008820155600681015460078201555b5f610db96117f2565b60088101549091508015610e0c575f6008830155610dd681611926565b60405181815233907fc9695243a805adb74c91f28311176c65b417e842d5699893cef56d18bfa48cba9060200160405180910390a25b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610e575750825b90505f8267ffffffffffffffff166001148015610e735750303b155b905081158015610e81575080155b15610e9f5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ec957845460ff60401b1916600160401b1785555b6001600160a01b038716610ef05760405163d92e233d60e01b815260040160405180910390fd5b610ef986611994565b610f016119a5565b610f4f6040518060400160405280600d81526020016c5374616b65642044696e65726f60981b815250604051806040016040528060078152602001667344494e45524f60c81b8152506119b5565b5f610f586117f2565b80546001600160a01b03808b166001600160a01b031992831617835562093a80600b8401819055600c84015560029092018054928a1692909116919091179055508315610fdf57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b5f610ff16117f2565b600c0154905090565b5f611003611828565b5f61100c6117f2565b600181015490915033905f906001600160a01b0316821461102d578161102f565b845b90505f61103b876115c3565b9050805f0361105d57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0382166110845760405163d92e233d60e01b815260040160405180910390fd5b600b840154611093904261224a565b6001600160a01b038381165f818152600d880160209081526040918290209490945580518b81529384018590529092918616917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a38354611108906001600160a01b031684308a6119cb565b6111128282611a04565b61111b87611926565b935050505061069860015f8051602061245a83398151915255565b61113e6118f4565b6111475f611a38565b565b6111516118f4565b6001600160a01b0381166111785760405163d92e233d60e01b815260040160405180910390fd5b6040516001600160a01b03821681527ff52f1295a5bd82818185311d8284477532c0eba12fd2ba17314486d3a8f6810d9060200160405180910390a15f6111bd6117f2565b60020180546001600160a01b0319166001600160a01b03939093169290921790915550565b33806111ec611589565b6001600160a01b0316146112235760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61122c81611a38565b50565b5f6112386117f2565b60040154905090565b5f61124a6117f2565b600101546001600160a01b0316919050565b5f806112666115b1565b90508042106112755780611277565b425b91505090565b5f6112866117f2565b60090154905090565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0480546060915f8051602061243a833981519152916106039061225d565b5f61130a6117f2565b60080154905090565b5f8061133d7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b9050801561135d57611358611350610559565b849083611a70565b61135f565b5f5b9392505050565b5f61136f6117f2565b60070154905090565b5f334261138482610d2f565b11156113a3576040516303cb96db60e21b815260040160405180910390fd5b6113ad8484611a8b565b949350505050565b5f6113be6117f2565b600201546001600160a01b0316919050565b5f6113d96117f2565b60050154905090565b5f806113ec6117f2565b60098101549091505f819003611406575060060154919050565b808260040154836005015461141961125c565b6114239190612201565b61142d9190612214565b61143f90670de0b6b3a7640000612214565b611449919061222b565b8260060154611458919061224a565b9250505090565b5f806114696117f2565b90508060080154670de0b6b3a764000082600701546114866113e2565b6114909190612201565b836009015461149f9190612214565b6114a9919061222b565b611277919061224a565b6001600160a01b039182165f9081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020908152604080832093909416825291909152205490565b5f6115056117f2565b60060154905090565b6115166118f4565b5f61151f6117f2565b9050811580611532575080600c01548211155b1561155057604051637616640160e01b815260040160405180910390fd5b6040518281527f1c8e1d9e3756966daa8a54a45d27d3b2021ba44ae7b202e13dc58a96d12c84639060200160405180910390a1600c0155565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c006112b3565b5f6115ba6117f2565b60030154905090565b5f806115ed7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b905080156116095761135881611601610559565b859190611a70565b5090919050565b6116186118f4565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b038316908117825561165c61128f565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b5f33426116a182610d2f565b11156116c0576040516303cb96db60e21b815260040160405180910390fd5b5f6116ca84611313565b9050805f036116ec57604051631f2a200560e01b815260040160405180910390fd5b5f6116f56117f2565b9050806009015482111561170b5761170b610d6b565b81816009015f82825461171e9190612201565b925050819055508181600a015f828254611738919061224a565b9091555061174890503386611a98565b335f908152600e82016020908152604080832081518083019092528382529181019290925290600c83015461177d904261224a565b815260208082018581526001848101805480830182555f91825290849020855160029092020190815591519101556040805186815291820189905233917f95dcc40aa57d20084df6dd0373fc450f113a1682e31961ddf121e62614f0e86d910160405180910390a25091935050505b50919050565b7f189a25aed4a452a71e1e9aad4732cfcb1958b751d26283c9b5ff3524600e410090565b6118238383836001611acc565b505050565b5f8051602061245a83398151915280546001190161185957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b0383811660248301526044820183905261182391859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611bb0565b60015f8051602061245a83398151915255565b5f336118de858285611c11565b6118e9858585611c6e565b506001949350505050565b336118fd61128f565b6001600160a01b0316146111475760405163118cdaa760e01b815233600482015260240161121a565b60015f6119316117f2565b905061193b6113e2565b600682015561194861125c565b6005820155811561196b5761195b61145f565b6008820155600681015460078201555b5f6119746117f2565b905083816009015f828254611989919061224a565b909155505050505050565b61199c611ccb565b61122c81611d14565b6119ad611ccb565b611147611d45565b6119bd611ccb565b6119c78282611d4d565b5050565b6040516001600160a01b038481166024830152838116604483015260648201839052610e0c9186918216906323b872dd9060840161188c565b6001600160a01b038216611a2d5760405163ec442f0560e01b81525f600482015260240161121a565b6119c75f8383611d9d565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b03191681556119c782611ed6565b5f825f190484118302158202611a84575f80fd5b5091020490565b5f33610692818585611c6e565b6001600160a01b038216611ac157604051634b637e8f60e11b81525f600482015260240161121a565b6119c7825f83611d9d565b5f8051602061243a8339815191526001600160a01b038516611b035760405163e602df0560e01b81525f600482015260240161121a565b6001600160a01b038416611b2c57604051634a1406b160e11b81525f600482015260240161121a565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115611ba957836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051611ba091815260200190565b60405180910390a35b5050505050565b5f611bc46001600160a01b03841683611f46565b905080515f14158015611be8575080806020019051810190611be691906122fb565b155b1561182357604051635274afe760e01b81526001600160a01b038416600482015260240161121a565b5f611c1c84846114b3565b90505f198114610e0c5781811015611c6057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161121a565b610e0c84848484035f611acc565b6001600160a01b038316611c9757604051634b637e8f60e11b81525f600482015260240161121a565b6001600160a01b038216611cc05760405163ec442f0560e01b81525f600482015260240161121a565b611823838383611d9d565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661114757604051631afcd79f60e31b815260040160405180910390fd5b611d1c611ccb565b6001600160a01b03811661122357604051631e4fbdf760e01b81525f600482015260240161121a565b6118be611ccb565b611d55611ccb565b5f8051602061243a8339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03611d8e848261235e565b5060048101610e0c838261235e565b5f8051602061243a8339815191526001600160a01b038416611dd75781816002015f828254611dcc919061224a565b90915550611e479050565b6001600160a01b0384165f9081526020829052604090205482811015611e295760405163391434e360e21b81526001600160a01b0386166004820152602481018290526044810184905260640161121a565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316611e65576002810180548390039055611e83565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611ec891815260200190565b60405180910390a350505050565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b606061135f83835f845f80856001600160a01b03168486604051611f6a919061241e565b5f6040518083038185875af1925050503d805f8114611fa4576040519150601f19603f3d011682016040523d82523d5f602084013e611fa9565b606091505b5091509150611fb9868383611fc3565b9695505050505050565b606082611fd3576113588261201a565b8151158015611fea57506001600160a01b0384163b155b1561201357604051639996b31560e01b81526001600160a01b038516600482015260240161121a565b508061135f565b80511561202a5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f5b8381101561205d578181015183820152602001612045565b50505f910152565b602081525f8251806020840152612083816040850160208701612043565b601f01601f19169190910160400192915050565b6001600160a01b038116811461122c575f80fd5b5f80604083850312156120bc575f80fd5b82356120c781612097565b946020939093013593505050565b5f805f606084860312156120e7575f80fd5b83356120f281612097565b9250602084013561210281612097565b929592945050506040919091013590565b5f60208284031215612123575f80fd5b813561135f81612097565b5f6020828403121561213e575f80fd5b5035919050565b602080825282518282018190525f919060409081850190868401855b8281101561218657815180518552860151868501529284019290850190600101612161565b5091979650505050505050565b5f80604083850312156121a4575f80fd5b82356121af81612097565b915060208301356121bf81612097565b809150509250929050565b5f80604083850312156121db575f80fd5b8235915060208301356121bf81612097565b634e487b7160e01b5f52601160045260245ffd5b81810381811115610698576106986121ed565b8082028115828204841417610698576106986121ed565b5f8261224557634e487b7160e01b5f52601260045260245ffd5b500490565b80820180821115610698576106986121ed565b600181811c9082168061227157607f821691505b6020821081036117ec57634e487b7160e01b5f52602260045260245ffd5b5f6020828403121561229f575f80fd5b5051919050565b634e487b7160e01b5f52603260045260245ffd5b5f600182016122cb576122cb6121ed565b5060010190565b5f816122e0576122e06121ed565b505f190190565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561230b575f80fd5b8151801515811461135f575f80fd5b601f82111561182357805f5260205f20601f840160051c8101602085101561233f5750805b601f840160051c820191505b81811015611ba9575f815560010161234b565b815167ffffffffffffffff811115612378576123786122e7565b61238c81612386845461225d565b8461231a565b602080601f8311600181146123bf575f84156123a85750858301515b5f19600386901b1c1916600185901b178555612416565b5f85815260208120601f198616915b828110156123ed578886015182559484019460019091019084016123ce565b508582101561240a57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f825161242f818460208701612043565b919091019291505056fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220cb351dc4a0226e7622973af3d94271de96d1011e225a40b27c09a89ec342fae264736f6c63430008190033
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610281575f3560e01c806379ba509711610156578063bfe10928116100ca578063e1f2030211610084578063e1f20302146104fd578063e30c397814610510578063ebe2b12b14610518578063ef8b30f714610520578063f2fde38b14610533578063fe5be48114610546575f80fd5b8063bfe10928146104c2578063c8f33c91146104ca578063cd3daf9d146104d2578063d6f19262146104da578063dd62ed3e146104e2578063df136d65146104f5575f80fd5b80638da5cb5b1161011b5780638da5cb5b1461047c57806395d89b41146104845780639ec5a8941461048c578063a43b4ed114610494578063a8024b06146104a7578063a9059cbb146104af575f80fd5b806379ba5097146104545780637b0a47ee1461045c5780637cd07e471461046457806380faa57d1461046c578063817b1cd214610474575f80fd5b806335d16e17116101f8578063485cc955116101b2578063485cc955146103d757806367970cba146103ea5780636e553f65146103f257806370a0823114610405578063715018a61461043957806375619ab514610441575f80fd5b806335d16e171461038457806338d52e0f1461038c5780633ab15478146103ac5780633de6d3ee146103b4578063424c79ca146103c75780634641257d146103cf575f80fd5b80631e9a6950116102495780631e9a69501461030957806323b872dd1461031c57806323cf31181461032f5780632b71c8e414610342578063313ce5671461035557806335384aff14610364575f80fd5b806301e1d1141461028557806306fdde03146102a0578063095ea7b3146102b55780630c51dde4146102d857806318160ddd146102e2575b5f80fd5b61028d610559565b6040519081526020015b60405180910390f35b6102a86105c5565b6040516102979190612065565b6102c86102c33660046120ab565b610685565b6040519015158152602001610297565b6102e061069e565b005b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461028d565b61028d6103173660046120ab565b610842565b6102c861032a3660046120d5565b610a1d565b6102e061033d366004612113565b610a5c565b6102e061035036600461212e565b610af5565b60405160128152602001610297565b610377610372366004612113565b610b63565b6040516102979190612145565b61028d610cee565b610394610d05565b6040516001600160a01b039091168152602001610297565b61028d610d1d565b61028d6103c2366004612113565b610d2f565b61028d610d59565b6102e0610d6b565b6102e06103e5366004612193565b610e12565b61028d610fe8565b61028d6104003660046121ca565b610ffa565b61028d610413366004612113565b6001600160a01b03165f9081525f8051602061243a833981519152602052604090205490565b6102e0611136565b6102e061044f366004612113565b611149565b6102e06111e2565b61028d61122f565b610394611241565b61028d61125c565b61028d61127d565b61039461128f565b6102a86112c3565b61028d611301565b61028d6104a236600461212e565b611313565b61028d611366565b6102c86104bd3660046120ab565b611378565b6103946113b5565b61028d6113d0565b61028d6113e2565b61028d61145f565b61028d6104f0366004612193565b6114b3565b61028d6114fc565b6102e061050b36600461212e565b61150e565b610394611589565b61028d6115b1565b61028d61052e36600461212e565b6115c3565b6102e0610541366004612113565b611610565b61028d61055436600461212e565b611695565b5f806105636117f2565b90505f816009015490505f8260080154670de0b6b3a764000084600701546105896113e2565b6105939190612201565b61059d9085612214565b6105a7919061222b565b6105b1919061224a565b90506105bd818361224a565b935050505090565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0380546060915f8051602061243a833981519152916106039061225d565b80601f016020809104026020016040519081016040528092919081815260200182805461062f9061225d565b801561067a5780601f106106515761010080835404028352916020019161067a565b820191905f5260205f20905b81548152906001019060200180831161065d57829003601f168201915b505050505091505090565b5f33610692818585611816565b60019150505b92915050565b5f806106a86117f2565b90506106b26113e2565b60068201556106bf61125c565b600582015581156106e2576106d261145f565b6008820155600681015460078201555b5f6106eb6117f2565b60028101549091506001600160a01b0316331461071a576040516282b42960e81b815260040160405180910390fd5b5f61072361145f565b6009830154600a84015484546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610772573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610796919061228f565b6107a09190612201565b6107aa9190612201565b6107b49190612201565b90505f6107c462093a808361222b565b9050805f036107e657604051630fec21fd60e21b815260040160405180910390fd5b6004830181905542600584018190556108039062093a809061224a565b60038401556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050505050565b5f61084b611828565b6001600160a01b0383166108725760405163d92e233d60e01b815260040160405180910390fd5b5f61087b6117f2565b335f908152600e820160205260409020805460018201805493945091929091908083036108bb57604051631f2a200560e01b815260040160405180910390fd5b5f4281896108c957836108cb565b895b9050855b84811015610968575f8682815481106108ea576108ea6122a6565b905f5260205f2090600202016040518060400160405290815f8201548152602001600182015481525050905083815f01511115801561092857505f83115b1561095957602081015161093c908661224a565b9450610947886122ba565b9750610952836122d2565b925061095f565b50610968565b506001016108cf565b50825f0361098957604051631f2a200560e01b815260040160405180910390fd5b6040518381526001600160a01b038c169033907fd12200efa34901b99367694174c3b0d32c99585fdf37c7c26892136ddd0836d99060200160405180910390a3858755600a880180548491905f906109e2908490612201565b909155505087546109fd906001600160a01b03168c8561185f565b5090965050505050505061069860015f8051602061245a83398151915255565b5f8342610a2982610d2f565b1115610a48576040516303cb96db60e21b815260040160405180910390fd5b610a538585856118d1565b95945050505050565b610a646118f4565b6001600160a01b038116610a8b5760405163d92e233d60e01b815260040160405180910390fd5b6040516001600160a01b03821681527ff40543f3e605deae7fbca26db18ff1de07eda2925d68655836eae4c167444e329060200160405180910390a15f610ad06117f2565b60010180546001600160a01b0319166001600160a01b03939093169290921790915550565b610afd6118f4565b805f03610b1d57604051631f2a200560e01b815260040160405180910390fd5b6040518181527f8fe4a0bc6b45606382245a54a20e81f06b78455da7130159a8f7229d060987df9060200160405180910390a15f610b596117f2565b600b019190915550565b60605f610b6e6117f2565b90505f81600e015f856001600160a01b03166001600160a01b031681526020019081526020015f206040518060400160405290815f820154815260200160018201805480602002602001604051908101604052809291908181526020015f905b82821015610c11578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190610bce565b505050915250508051602082015180519293509091610c308382612201565b67ffffffffffffffff811115610c4857610c486122e7565b604051908082528060200260200182016040528015610c8c57816020015b604080518082019091525f8082526020820152815260200190600190039081610c665790505b5095505f835b82811015610ce2575f848281518110610cad57610cad6122a6565b6020026020010151905080898481518110610cca57610cca6122a6565b60209081029190910101525060019182019101610c92565b50505050505050919050565b5f610d00670de0b6b3a7640000611313565b905090565b5f610d0e6117f2565b546001600160a01b0316919050565b5f610d266117f2565b600a0154905090565b5f610d386117f2565b6001600160a01b039092165f908152600d9290920160205250604090205490565b5f610d626117f2565b600b0154905090565b60015f610d766117f2565b9050610d806113e2565b6006820155610d8d61125c565b60058201558115610db057610da061145f565b6008820155600681015460078201555b5f610db96117f2565b60088101549091508015610e0c575f6008830155610dd681611926565b60405181815233907fc9695243a805adb74c91f28311176c65b417e842d5699893cef56d18bfa48cba9060200160405180910390a25b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff165f81158015610e575750825b90505f8267ffffffffffffffff166001148015610e735750303b155b905081158015610e81575080155b15610e9f5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ec957845460ff60401b1916600160401b1785555b6001600160a01b038716610ef05760405163d92e233d60e01b815260040160405180910390fd5b610ef986611994565b610f016119a5565b610f4f6040518060400160405280600d81526020016c5374616b65642044696e65726f60981b815250604051806040016040528060078152602001667344494e45524f60c81b8152506119b5565b5f610f586117f2565b80546001600160a01b03808b166001600160a01b031992831617835562093a80600b8401819055600c84015560029092018054928a1692909116919091179055508315610fdf57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b5f610ff16117f2565b600c0154905090565b5f611003611828565b5f61100c6117f2565b600181015490915033905f906001600160a01b0316821461102d578161102f565b845b90505f61103b876115c3565b9050805f0361105d57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0382166110845760405163d92e233d60e01b815260040160405180910390fd5b600b840154611093904261224a565b6001600160a01b038381165f818152600d880160209081526040918290209490945580518b81529384018590529092918616917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a38354611108906001600160a01b031684308a6119cb565b6111128282611a04565b61111b87611926565b935050505061069860015f8051602061245a83398151915255565b61113e6118f4565b6111475f611a38565b565b6111516118f4565b6001600160a01b0381166111785760405163d92e233d60e01b815260040160405180910390fd5b6040516001600160a01b03821681527ff52f1295a5bd82818185311d8284477532c0eba12fd2ba17314486d3a8f6810d9060200160405180910390a15f6111bd6117f2565b60020180546001600160a01b0319166001600160a01b03939093169290921790915550565b33806111ec611589565b6001600160a01b0316146112235760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61122c81611a38565b50565b5f6112386117f2565b60040154905090565b5f61124a6117f2565b600101546001600160a01b0316919050565b5f806112666115b1565b90508042106112755780611277565b425b91505090565b5f6112866117f2565b60090154905090565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0480546060915f8051602061243a833981519152916106039061225d565b5f61130a6117f2565b60080154905090565b5f8061133d7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b9050801561135d57611358611350610559565b849083611a70565b61135f565b5f5b9392505050565b5f61136f6117f2565b60070154905090565b5f334261138482610d2f565b11156113a3576040516303cb96db60e21b815260040160405180910390fd5b6113ad8484611a8b565b949350505050565b5f6113be6117f2565b600201546001600160a01b0316919050565b5f6113d96117f2565b60050154905090565b5f806113ec6117f2565b60098101549091505f819003611406575060060154919050565b808260040154836005015461141961125c565b6114239190612201565b61142d9190612214565b61143f90670de0b6b3a7640000612214565b611449919061222b565b8260060154611458919061224a565b9250505090565b5f806114696117f2565b90508060080154670de0b6b3a764000082600701546114866113e2565b6114909190612201565b836009015461149f9190612214565b6114a9919061222b565b611277919061224a565b6001600160a01b039182165f9081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020908152604080832093909416825291909152205490565b5f6115056117f2565b60060154905090565b6115166118f4565b5f61151f6117f2565b9050811580611532575080600c01548211155b1561155057604051637616640160e01b815260040160405180910390fd5b6040518281527f1c8e1d9e3756966daa8a54a45d27d3b2021ba44ae7b202e13dc58a96d12c84639060200160405180910390a1600c0155565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c006112b3565b5f6115ba6117f2565b60030154905090565b5f806115ed7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b905080156116095761135881611601610559565b859190611a70565b5090919050565b6116186118f4565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b038316908117825561165c61128f565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b5f33426116a182610d2f565b11156116c0576040516303cb96db60e21b815260040160405180910390fd5b5f6116ca84611313565b9050805f036116ec57604051631f2a200560e01b815260040160405180910390fd5b5f6116f56117f2565b9050806009015482111561170b5761170b610d6b565b81816009015f82825461171e9190612201565b925050819055508181600a015f828254611738919061224a565b9091555061174890503386611a98565b335f908152600e82016020908152604080832081518083019092528382529181019290925290600c83015461177d904261224a565b815260208082018581526001848101805480830182555f91825290849020855160029092020190815591519101556040805186815291820189905233917f95dcc40aa57d20084df6dd0373fc450f113a1682e31961ddf121e62614f0e86d910160405180910390a25091935050505b50919050565b7f189a25aed4a452a71e1e9aad4732cfcb1958b751d26283c9b5ff3524600e410090565b6118238383836001611acc565b505050565b5f8051602061245a83398151915280546001190161185957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6040516001600160a01b0383811660248301526044820183905261182391859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611bb0565b60015f8051602061245a83398151915255565b5f336118de858285611c11565b6118e9858585611c6e565b506001949350505050565b336118fd61128f565b6001600160a01b0316146111475760405163118cdaa760e01b815233600482015260240161121a565b60015f6119316117f2565b905061193b6113e2565b600682015561194861125c565b6005820155811561196b5761195b61145f565b6008820155600681015460078201555b5f6119746117f2565b905083816009015f828254611989919061224a565b909155505050505050565b61199c611ccb565b61122c81611d14565b6119ad611ccb565b611147611d45565b6119bd611ccb565b6119c78282611d4d565b5050565b6040516001600160a01b038481166024830152838116604483015260648201839052610e0c9186918216906323b872dd9060840161188c565b6001600160a01b038216611a2d5760405163ec442f0560e01b81525f600482015260240161121a565b6119c75f8383611d9d565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b03191681556119c782611ed6565b5f825f190484118302158202611a84575f80fd5b5091020490565b5f33610692818585611c6e565b6001600160a01b038216611ac157604051634b637e8f60e11b81525f600482015260240161121a565b6119c7825f83611d9d565b5f8051602061243a8339815191526001600160a01b038516611b035760405163e602df0560e01b81525f600482015260240161121a565b6001600160a01b038416611b2c57604051634a1406b160e11b81525f600482015260240161121a565b6001600160a01b038086165f90815260018301602090815260408083209388168352929052208390558115611ba957836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92585604051611ba091815260200190565b60405180910390a35b5050505050565b5f611bc46001600160a01b03841683611f46565b905080515f14158015611be8575080806020019051810190611be691906122fb565b155b1561182357604051635274afe760e01b81526001600160a01b038416600482015260240161121a565b5f611c1c84846114b3565b90505f198114610e0c5781811015611c6057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161121a565b610e0c84848484035f611acc565b6001600160a01b038316611c9757604051634b637e8f60e11b81525f600482015260240161121a565b6001600160a01b038216611cc05760405163ec442f0560e01b81525f600482015260240161121a565b611823838383611d9d565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661114757604051631afcd79f60e31b815260040160405180910390fd5b611d1c611ccb565b6001600160a01b03811661122357604051631e4fbdf760e01b81525f600482015260240161121a565b6118be611ccb565b611d55611ccb565b5f8051602061243a8339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03611d8e848261235e565b5060048101610e0c838261235e565b5f8051602061243a8339815191526001600160a01b038416611dd75781816002015f828254611dcc919061224a565b90915550611e479050565b6001600160a01b0384165f9081526020829052604090205482811015611e295760405163391434e360e21b81526001600160a01b0386166004820152602481018290526044810184905260640161121a565b6001600160a01b0385165f9081526020839052604090209083900390555b6001600160a01b038316611e65576002810180548390039055611e83565b6001600160a01b0383165f9081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611ec891815260200190565b60405180910390a350505050565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b606061135f83835f845f80856001600160a01b03168486604051611f6a919061241e565b5f6040518083038185875af1925050503d805f8114611fa4576040519150601f19603f3d011682016040523d82523d5f602084013e611fa9565b606091505b5091509150611fb9868383611fc3565b9695505050505050565b606082611fd3576113588261201a565b8151158015611fea57506001600160a01b0384163b155b1561201357604051639996b31560e01b81526001600160a01b038516600482015260240161121a565b508061135f565b80511561202a5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f5b8381101561205d578181015183820152602001612045565b50505f910152565b602081525f8251806020840152612083816040850160208701612043565b601f01601f19169190910160400192915050565b6001600160a01b038116811461122c575f80fd5b5f80604083850312156120bc575f80fd5b82356120c781612097565b946020939093013593505050565b5f805f606084860312156120e7575f80fd5b83356120f281612097565b9250602084013561210281612097565b929592945050506040919091013590565b5f60208284031215612123575f80fd5b813561135f81612097565b5f6020828403121561213e575f80fd5b5035919050565b602080825282518282018190525f919060409081850190868401855b8281101561218657815180518552860151868501529284019290850190600101612161565b5091979650505050505050565b5f80604083850312156121a4575f80fd5b82356121af81612097565b915060208301356121bf81612097565b809150509250929050565b5f80604083850312156121db575f80fd5b8235915060208301356121bf81612097565b634e487b7160e01b5f52601160045260245ffd5b81810381811115610698576106986121ed565b8082028115828204841417610698576106986121ed565b5f8261224557634e487b7160e01b5f52601260045260245ffd5b500490565b80820180821115610698576106986121ed565b600181811c9082168061227157607f821691505b6020821081036117ec57634e487b7160e01b5f52602260045260245ffd5b5f6020828403121561229f575f80fd5b5051919050565b634e487b7160e01b5f52603260045260245ffd5b5f600182016122cb576122cb6121ed565b5060010190565b5f816122e0576122e06121ed565b505f190190565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561230b575f80fd5b8151801515811461135f575f80fd5b601f82111561182357805f5260205f20601f840160051c8101602085101561233f5750805b601f840160051c820191505b81811015611ba9575f815560010161234b565b815167ffffffffffffffff811115612378576123786122e7565b61238c81612386845461225d565b8461231a565b602080601f8311600181146123bf575f84156123a85750858301515b5f19600386901b1c1916600185901b178555612416565b5f85815260208120601f198616915b828110156123ed578886015182559484019460019091019084016123ce565b508582101561240a57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f825161242f818460208701612043565b919091019291505056fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220cb351dc4a0226e7622973af3d94271de96d1011e225a40b27c09a89ec342fae264736f6c63430008190033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.