Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
Staking
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 10000 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
/*
.____ ________
| | _____ ___.__. __________\_____ \
| | \__ \< | |/ __ \_ __ \_(__ <
| |___ / __ \\___ \ ___/| | \/ \
|_______ (____ / ____|\___ >__| /______ /
\/ \/\/ \/ \/
https://layer3.xyz
Made with ♥ by Wonderland (https://defi.sucks)
*/
import {IDistributor} from 'interfaces/IDistributor.sol';
import {IStaking} from 'interfaces/IStaking.sol';
import {Ownable2StepUpgradeable} from 'openzeppelin-upgradeable/access/Ownable2StepUpgradeable.sol';
import {UUPSUpgradeable} from 'openzeppelin-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import {PausableUpgradeable} from 'openzeppelin-upgradeable/utils/PausableUpgradeable.sol';
import {IERC20, SafeERC20} from 'openzeppelin/token/ERC20/utils/SafeERC20.sol';
import {Math} from 'openzeppelin/utils/math/Math.sol';
import {SafeCast} from 'openzeppelin/utils/math/SafeCast.sol';
contract Staking is IStaking, Ownable2StepUpgradeable, UUPSUpgradeable, PausableUpgradeable {
using SafeERC20 for IERC20;
using SafeCast for uint256;
using Math for uint256;
/// @notice The lockup periods
uint256 internal constant _12_MONTHS = 12 * 30 days;
uint256 internal constant _18_MONTHS = 18 * 30 days;
uint256 internal constant _24_MONTHS = 24 * 30 days;
uint256 internal constant _36_MONTHS = 36 * 30 days;
/// @notice The base value for calculations
uint256 internal constant _BASE = 1e18;
/// @inheritdoc IStaking
IERC20 public token;
/// @inheritdoc IStaking
IDistributor public distributor;
/// @inheritdoc IStaking
uint256 public rewardsDuration;
/// @inheritdoc IStaking
uint256 public periodFinish;
/// @inheritdoc IStaking
uint256 public lastUpdateTime;
/// @inheritdoc IStaking
uint256 public rewardPerSecond;
/// @inheritdoc IStaking
uint256 public rewardPerShare;
/// @inheritdoc IStaking
uint256 public totalRewards;
/// @inheritdoc IStaking
uint256 public totalDeposits;
/// @inheritdoc IStaking
uint256 public totalWeights;
/// @inheritdoc IStaking
uint256 public withdrawalPeriod;
/// @inheritdoc IStaking
mapping(address _user => Staker _staker) public stakers;
/// @inheritdoc IStaking
mapping(address _user => mapping(uint256 _index => Deposit _deposit)) public deposits;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(IERC20 _token, IDistributor _distributor, address _owner) public initializer {
token = _token;
distributor = _distributor;
rewardsDuration = 5 * 12 * 30 days;
withdrawalPeriod = 7 days;
__Ownable_init(_owner);
__Ownable2Step_init();
__UUPSUpgradeable_init();
__Pausable_init();
_pause();
}
/// @inheritdoc IStaking
function stake(uint256 _amount, uint256 _lockupPeriod) external {
Deposit memory _deposit = _stake(_amount, _lockupPeriod, msg.sender);
emit Staked(msg.sender, _deposit.index, _deposit.amount, _deposit.lockupPeriod, _deposit.unlockAt);
// Transfer the tokens to the contract
token.safeTransferFrom(msg.sender, address(this), _amount);
}
/// @inheritdoc IStaking
function stake(uint256 _amount, uint256 _lockupPeriod, address _user) external {
if (msg.sender != address(distributor)) revert OnlyDistributor();
// The distributor will transfer the tokens after calling this function
Deposit memory _deposit = _stake(_amount, _lockupPeriod, _user);
emit Staked(_user, _deposit.index, _deposit.amount, _deposit.lockupPeriod, _deposit.unlockAt);
}
/// @inheritdoc IStaking
function increaseStake(uint256 _index, uint256 _amount) external {
_increaseStake(_index, _amount, msg.sender);
emit StakeIncreased(msg.sender, _index, _amount);
// Transfer the tokens to the contract
token.safeTransferFrom(msg.sender, address(this), _amount);
}
/// @inheritdoc IStaking
function stakeUnlocked(uint256 _index, uint256 _newLockupPeriod) external {
Deposit memory _currentDeposit = deposits[msg.sender][_index];
uint256 _currentAmount = _currentDeposit.amount;
if (_currentAmount == 0) revert InvalidDepositIndex();
if (_currentDeposit.unlockAt > block.timestamp) revert DepositLocked();
if (_currentDeposit.withdrawAt > 0) revert WithdrawalAlreadyInitiated();
if (_currentDeposit.lockupPeriod >= _newLockupPeriod) revert InvalidLockupPeriod();
// Close the current stake
_decreaseStake(_currentDeposit);
// Delete the current staked deposit
delete deposits[msg.sender][_index];
totalDeposits -= _currentAmount;
// Stake using the same amount but with the new lockup period
Deposit memory _newDeposit = _stake(_currentAmount, _newLockupPeriod, msg.sender);
emit StakedUnlocked(
msg.sender, _newDeposit.index, _newDeposit.amount, _newDeposit.lockupPeriod, _newDeposit.unlockAt
);
}
/// @inheritdoc IStaking
function getReward() external {
Staker storage _staker = _updateReward(msg.sender);
uint256 _reward = _staker.pendingRewards;
if (_reward > 0) {
_staker.pendingRewards = 0;
totalRewards -= _reward;
token.safeTransfer(msg.sender, _reward);
emit RewardPaid(msg.sender, _reward);
}
}
/// @inheritdoc IStaking
function getRewardAndStake(uint256 _lockupPeriod) external {
Staker storage _staker = _updateReward(msg.sender);
uint256 _reward = _staker.pendingRewards;
if (_reward > 0) {
_staker.pendingRewards = 0;
Deposit memory _deposit = _stake(_reward, _lockupPeriod, msg.sender);
totalRewards -= _reward;
emit ClaimRewardAndStake(msg.sender, _deposit.index, _reward, _lockupPeriod);
}
}
/// @inheritdoc IStaking
function getRewardAndIncreaseStake(uint256 _index) external {
Staker storage _staker = _updateReward(msg.sender);
uint256 _reward = _staker.pendingRewards;
if (_reward > 0) {
_staker.pendingRewards = 0;
_increaseStake(_index, _reward, msg.sender);
totalRewards -= _reward;
emit ClaimRewardAndIncreaseStake(msg.sender, _index, _reward);
}
}
/// @inheritdoc IStaking
function initiateWithdrawal(uint256 _index) external {
// Get the Deposit struct
Deposit storage _deposit = deposits[msg.sender][_index];
if (_deposit.amount == 0) revert InvalidDepositIndex();
if (_deposit.lockupPeriod > 0) revert DepositLocked();
if (_deposit.withdrawAt > 0) revert WithdrawalAlreadyInitiated();
_decreaseStake(_deposit);
// Update the withdrawal timestamp
_deposit.withdrawAt = (block.timestamp + withdrawalPeriod).toUint40();
emit WithdrawalInitiated(msg.sender, _index, _deposit.withdrawAt);
}
/// @inheritdoc IStaking
function cancelWithdrawal(uint256 _index) external {
// Get the Deposit struct
Deposit storage _deposit = deposits[msg.sender][_index];
uint256 _amount = _deposit.amount;
if (_deposit.amount == 0) revert InvalidDepositIndex();
if (_deposit.withdrawAt == 0) revert WithdrawalNotInitiated();
Staker storage _staker = _updateReward(msg.sender);
// Because the deposit is unlocked, we're calculating the weight with a lockup period of 0
uint256 _weight = _calculateWeight(0, _amount);
// Update the total weights and user weight and reset the withdrawal timestamp
totalWeights += _weight;
_staker.weight += _weight.toUint128();
_deposit.withdrawAt = 0;
emit WithdrawalCancelled(msg.sender, _index);
}
/// @inheritdoc IStaking
function withdraw(uint256 _index) external {
// Get the Deposit struct
Deposit memory _deposit = deposits[msg.sender][_index];
if (_deposit.amount == 0) revert InvalidDepositIndex();
if (_deposit.lockupPeriod > 0) {
if (_deposit.unlockAt > block.timestamp) revert DepositLocked();
_decreaseStake(_deposit);
} else if (withdrawalPeriod == 0 && _deposit.withdrawAt == 0) {
_decreaseStake(_deposit);
} else {
// Non-lockup deposits can be withdrawn only after a withdrawal period
if (_deposit.withdrawAt > block.timestamp) revert DepositNotWithdrawable();
if (_deposit.withdrawAt == 0) revert WithdrawalNotInitiated();
// Not updating weights because the deposit was already removed from the total in `initiateWithdrawal`
}
// Update the total deposits
totalDeposits -= _deposit.amount;
// Delete the deposit
delete deposits[msg.sender][_index];
// Transfer the tokens to the user
token.safeTransfer(msg.sender, _deposit.amount);
emit Withdrawn(msg.sender, _index, _deposit.amount);
}
/// @inheritdoc IStaking
function emergencyWithdraw(uint256 _amount) external onlyOwner {
if (_amount == 0) revert ZeroAmount();
// Withdraw either the requested amount or the remaining balance
uint256 _remainingBalance = token.balanceOf(address(this));
uint256 _withdrawalAmount = _amount > _remainingBalance ? _remainingBalance : _amount;
token.safeTransfer(owner(), _withdrawalAmount);
emit EmergencyWithdrawn(owner(), _withdrawalAmount);
}
/// @inheritdoc IStaking
function setRewardAmount(uint256 _reward) external onlyOwner {
uint256 _currentBalance = token.balanceOf(address(this));
if (_reward > _currentBalance - totalDeposits - totalRewards) revert InsufficientBalance();
_updateReward(address(0));
if (block.timestamp >= periodFinish) {
rewardPerSecond = _reward / rewardsDuration;
} else {
uint256 _remaining = periodFinish - block.timestamp;
uint256 _leftover = _remaining * rewardPerSecond;
rewardPerSecond = (_reward + _leftover) / rewardsDuration;
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp + rewardsDuration;
totalRewards += _reward;
emit RewardAdded(_reward);
}
/// @inheritdoc IStaking
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
if (periodFinish > block.timestamp) revert PeriodNotFinished();
uint256 _oldRewardsDuration = rewardsDuration;
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(_oldRewardsDuration, _rewardsDuration);
}
/// @inheritdoc IStaking
function setWithdrawalPeriod(uint256 _withdrawalPeriod) external onlyOwner {
uint256 _oldWithdrawalPeriod = withdrawalPeriod;
withdrawalPeriod = _withdrawalPeriod;
emit WithdrawalPeriodUpdated(_oldWithdrawalPeriod, _withdrawalPeriod);
}
/// @inheritdoc IStaking
function pause() external onlyOwner {
_pause();
}
/// @inheritdoc IStaking
function unpause() external onlyOwner {
_unpause();
}
/// @inheritdoc IStaking
function setDistributorAddress(IDistributor _distributor) external onlyOwner {
IDistributor _oldDistributor = distributor;
distributor = _distributor;
emit DistributorUpdated(_oldDistributor, _distributor);
}
/// @inheritdoc IStaking
function collectDust(IERC20 _token, uint256 _amount) external onlyOwner {
if (_token == token || address(_token) == address(0)) revert InvalidToken();
if (_amount == 0) revert ZeroAmount();
address _owner = owner();
_token.safeTransfer(_owner, _amount);
emit DustCollected(_owner, _token, _amount);
}
/// @inheritdoc IStaking
function calculateAPY(uint256 _amount, uint256 _lockupPeriod) external view returns (uint256 _apy) {
uint256 _weight = _calculateWeight(_lockupPeriod, _amount);
uint256 _rewardPerYear = rewardPerSecond * _12_MONTHS * _BASE * 100;
_apy = Math.mulDiv(_weight, _rewardPerYear, (totalWeights + _weight) * _amount);
}
/// @inheritdoc IStaking
function calculateAPY(address _user, uint256 _index) external view returns (uint256 _apy) {
Deposit memory _deposit = deposits[_user][_index];
uint256 _weight = _calculateWeight(_deposit.lockupPeriod, _deposit.amount);
uint256 _rewardPerYear = rewardPerSecond * _12_MONTHS * _BASE * 100;
_apy = Math.mulDiv(_weight, _rewardPerYear, _deposit.amount * totalWeights);
}
/// @inheritdoc IStaking
function listDeposits(
address _user,
uint256 _startFrom,
uint256 _batchSize
) external view returns (Deposit[] memory _list) {
uint256 _totalDeposits = stakers[_user].depositCount;
// Return an empty array if non-existent user or no deposits
if (_startFrom > _totalDeposits) {
return _list;
}
if (_batchSize > _totalDeposits - _startFrom) {
_batchSize = _totalDeposits - _startFrom;
}
_list = new Deposit[](_batchSize);
uint256 _index;
while (_index < _batchSize) {
_list[_index] = deposits[_user][_startFrom + _index];
++_index;
}
}
/// @inheritdoc IStaking
function pendingRewards(address _user) public view returns (uint256 _pendingRewards) {
Staker storage _staker = stakers[_user];
// Staker's pendingRewards already accounts for rewards calculated prior to the last snapshot
// We take the difference between the current rate and the one pendingRewards was calculated at
// And work out the amount of rewards accumulated after the snapshot
uint256 _rateDifferenceSinceSnapshot = _calculatedRewardPerShare() - _staker.rewardPerShareSnapshot;
uint256 _rewardsSinceSnapshot = _staker.weight * _rateDifferenceSinceSnapshot / _BASE;
_pendingRewards = _staker.pendingRewards + _rewardsSinceSnapshot;
}
/**
* @notice Stakes the provided amount of tokens and increases the total weight
* @param _amount The amount of tokens
* @param _lockupPeriod The lockup period
* @param _user The address of the user
*/
function _stake(uint256 _amount, uint256 _lockupPeriod, address _user) internal returns (Deposit memory _deposit) {
if (_amount == 0) revert ZeroAmount();
Staker storage _staker = _updateReward(_user);
// Calculate the user weight, taking into account the lockup period multiplier
uint256 _weight = _calculateWeight(_lockupPeriod, _amount);
if (_weight == 0) revert ZeroWeight();
// Update the total weights and user weight
totalWeights += _weight;
totalDeposits += _amount;
_staker.weight += _weight.toUint128();
// Get the last index and increment it
uint256 _lastIndex = _staker.depositCount++;
uint256 _unlockAt = block.timestamp + _lockupPeriod;
_deposit = Deposit({
amount: _amount.toUint128(),
unlockAt: _unlockAt.toUint40(),
lockupPeriod: _lockupPeriod.toUint32(),
index: _lastIndex.toUint16(),
withdrawAt: 0
});
// Create a new Deposit struct
deposits[_user][_lastIndex] = _deposit;
}
/**
* @notice Updates the reward rate and the staker's info
* @param _user The address of the user
* @return _staker The staker struct
*/
function _updateReward(address _user) internal whenNotPaused returns (Staker storage _staker) {
uint256 _rewardPerShare = _calculatedRewardPerShare();
if (_rewardPerShare == 0 || _rewardPerShare > rewardPerShare) {
rewardPerShare = _rewardPerShare;
lastUpdateTime = _lastTimeRewardApplicable();
}
_staker = stakers[_user];
if (_user != address(0)) {
_staker.pendingRewards = pendingRewards(_user).toUint128();
_staker.rewardPerShareSnapshot = rewardPerShare.toUint128();
}
}
/**
* @notice Adds the specified amount of tokens the specified deposit
* @param _index The index of the deposit
* @param _amount The amount of tokens
* @param _user The address of the user
* @dev Only unlocked deposits can be increased
*/
function _increaseStake(uint256 _index, uint256 _amount, address _user) internal {
Deposit storage _deposit = deposits[_user][_index];
if (_deposit.amount == 0) revert InvalidDepositIndex();
if (_deposit.lockupPeriod > 0) revert CannotIncreaseLockedStake();
if (_deposit.withdrawAt > 0) revert WithdrawalAlreadyInitiated();
// Because the deposit is unlocked, we're calculating the weight with a lockup period of 0
uint256 _weight = _calculateWeight(0, _amount);
// Update the total weights and user weight
Staker storage _staker = _updateReward(_user);
totalWeights += _weight;
totalDeposits += _amount;
_staker.weight += _weight.toUint128();
_deposit.amount += _amount.toUint128();
}
/**
* @notice Decreases the stake of the specified deposit
* @param _deposit The deposit to decrease
*/
function _decreaseStake(Deposit memory _deposit) internal {
Staker storage _staker = _updateReward(msg.sender);
// Calculate the user weight
uint256 _weight = _calculateWeight(_deposit.lockupPeriod, _deposit.amount);
// Avoid rounding issues where `weight(a) + weight(b) <= weight(a+b)` that may cause underflows
_weight = _weight <= _staker.weight ? _weight : _staker.weight;
// Update the total weights and user weight
totalWeights -= _weight;
_staker.weight -= _weight.toUint128();
}
/**
* @notice Returns either the current time or the end of the rewards period, whichever is earlier
* @return _lastTimeReward The timestamp of the last time rewards were applicable
*/
function _lastTimeRewardApplicable() internal view returns (uint256 _lastTimeReward) {
_lastTimeReward = block.timestamp < periodFinish ? block.timestamp : periodFinish;
}
/**
* @notice Calculates the reward per share
* @return _rewardPerShare The reward per share
*/
function _calculatedRewardPerShare() internal view returns (uint256 _rewardPerShare) {
if (totalWeights == 0) {
return rewardPerShare;
}
uint256 _timeSinceLastUpdate = _lastTimeRewardApplicable() - lastUpdateTime;
_rewardPerShare = rewardPerShare + _timeSinceLastUpdate * rewardPerSecond * _BASE / totalWeights;
}
/**
* @notice Applies the lockup period multiplier to get the deposit's weight
* @param _lockupPeriod The lockup period
* @param _amount The amount of tokens
* @return _weight The weight of the deposit
*/
function _calculateWeight(uint256 _lockupPeriod, uint256 _amount) internal pure returns (uint256 _weight) {
if (_lockupPeriod == 0) {
_weight = _amount * 250 / 1000;
} else if (_lockupPeriod == _12_MONTHS) {
_weight = _amount * 500 / 1000;
} else if (_lockupPeriod == _18_MONTHS) {
_weight = _amount * 625 / 1000;
} else if (_lockupPeriod == _24_MONTHS) {
_weight = _amount * 750 / 1000;
} else if (_lockupPeriod == _36_MONTHS) {
_weight = _amount;
} else {
revert InvalidLockupPeriod();
}
}
/**
* @notice Checks if the contract upgrade is authorized
* @param _newImplementation The address of the new implementation
* @dev Only owner should be allowed to perform upgrades
*/
function _authorizeUpgrade(address _newImplementation) internal override onlyOwner {}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {IStaking} from 'interfaces/IStaking.sol';
import {IERC20} from 'openzeppelin/token/ERC20/IERC20.sol';
/**
* @title Distributor Contract
* @author Wonderland (https://defi.sucks)
* @notice Distributes tokens to users based on a merkle root and a signature
*/
interface IDistributor {
/*///////////////////////////////////////////////////////////////
EVENTS
///////////////////////////////////////////////////////////////*/
/**
* @notice Emitted when a user claims their tokens
* @param _account The account that claimed the tokens
* @param _amount The amount of tokens claimed
*/
event Claimed(address indexed _account, uint256 _amount);
/**
* @notice Emitted when a user claims and stakes their tokens
* @param _account The account that claimed and staked the tokens
* @param _amount The amount of tokens claimed and staked
* @param _lockupPeriod The lockup period for the deposit
* @param _timestamp The timestamp at which the tokens were claimed and staked
*/
event ClaimedAndStaked(address indexed _account, uint256 _amount, uint256 _lockupPeriod, uint256 _timestamp);
/**
* @notice Emitted when the owner withdraws tokens from the contract
* @param _owner The owner that withdrew the tokens
* @param _amount The amount of tokens withdrawn
*/
event EmergencyWithdrawn(address indexed _owner, uint256 _amount);
/**
* @notice Emitted when the signer is updated by the owner
* @param _oldSigner The old signer address
* @param _newSigner The new signer address
*/
event SignerUpdated(address indexed _oldSigner, address indexed _newSigner);
/**
* @notice Emitted when the owner collects dust tokens from the contract
* @param _owner The owner that collected the dust tokens
* @param _token The token address
* @param _amount The amount of tokens collected
*/
event DustCollected(address indexed _owner, IERC20 indexed _token, uint256 _amount);
/*///////////////////////////////////////////////////////////////
ERRORS
///////////////////////////////////////////////////////////////*/
/**
* @notice Throws if the input amount is zero
*/
error ZeroAmount();
/**
* @notice Throws if the user has already claimed their tokens
*/
error AlreadyClaimed();
/**
* @notice Throws if the recovered signer is different from the expected signer
*/
error InvalidSigner();
/**
* @notice Throws if the merkle verification fails
*/
error InvalidProof();
/**
* @notice Throws if the new signer address is invalid
*/
error InvalidNewSigner();
/**
* @notice Throws if the input token is invalid
*/
error InvalidToken();
/*///////////////////////////////////////////////////////////////
LOGIC
///////////////////////////////////////////////////////////////*/
/**
* @notice Verifies eligibility and transfers the tokens to the caller
* @param _amount The amount of tokens to claim
* @param _merkleProof The merkle proof of the claim
* @param _signature The signature provided by the UI
*/
function claim(uint256 _amount, bytes32[] calldata _merkleProof, bytes calldata _signature) external;
/**
* @notice Verifies eligibility and stakes the claimed tokens in the contract
* @param _amount The amount of tokens to claim
* @param _merkleProof The merkle proof for the claim
* @param _signature The signature for verification of the claim data
* @param _lockupPeriod The period of time to lock the tokens for
*/
function claimAndStake(
uint256 _amount,
bytes32[] calldata _merkleProof,
bytes calldata _signature,
uint32 _lockupPeriod
) external;
/**
* @notice Sends any remaining tokens to the owner
* @dev Only callable by the owner
* @dev If the specified amount exceeds the available balance, the entire balance is withdrawn
* @param _amount The amount of tokens to withdraw
*/
function emergencyWithdraw(uint256 _amount) external;
/**
* @notice Updates the signer address
* @dev Only callable by the owner
* @param _newSigner The new signer address
*/
function updateSigner(address _newSigner) external;
/**
* @notice Collects dust tokens from the contract
* @dev Only the owner can call this function
* @param _token The token to collect
* @param _amount The amount of tokens to collect
*/
function collectDust(IERC20 _token, uint256 _amount) external;
/*///////////////////////////////////////////////////////////////
VARIABLES
///////////////////////////////////////////////////////////////*/
/**
* @notice The root of the merkle tree
* @return _merkleRoot The root of the merkle tree
*/
// solhint-disable-next-line func-name-mixedcase
function MERKLE_ROOT() external view returns (bytes32 _merkleRoot);
/**
* @notice The token being distributed
* @return _token The address of the token
*/
// solhint-disable-next-line func-name-mixedcase
function TOKEN() external view returns (IERC20 _token);
/**
* @notice The address of the staking contract
* @return _staking The staking contract
*/
// solhint-disable-next-line func-name-mixedcase
function STAKING() external view returns (IStaking _staking);
/**
* @notice The address of the signer
* @return _signer The address of the signer
*/
function signer() external view returns (address _signer);
/**
* @notice Returns whether the user has claimed their tokens
* @param _user The address of the user
* @return _claimed Whether the user has claimed their tokens
*/
function hasClaimed(address _user) external view returns (bool _claimed);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {IDistributor} from './IDistributor.sol';
import {IERC20} from 'openzeppelin/token/ERC20/utils/SafeERC20.sol';
interface IStaking {
/*///////////////////////////////////////////////////////////////
STRUCTS
///////////////////////////////////////////////////////////////*/
/**
* @notice Deposit struct
* @param amount The amount of tokens deposited
* @param unlockAt The timestamp when the tokens can be unlocked
* @param lockupPeriod The period the tokens are locked for to get the bonus
* @param index The index of the deposit
* @param withdrawAt The timestamp when the tokens can be withdrawn (after withdrawal period is over)
*/
struct Deposit {
uint128 amount;
uint40 unlockAt;
uint32 lockupPeriod;
uint16 index;
uint40 withdrawAt;
}
/**
* @notice Staker struct
* @param weight The combined weight of the staker's deposits
* @param depositCount The number of deposits the staker has
* @param rewardPerShareSnapshot The amount of rewards per share as seen at the last update
* @param pendingRewards The amount of rewards available to be claimed by the staker
*/
struct Staker {
uint128 weight;
uint128 depositCount;
uint128 rewardPerShareSnapshot;
uint128 pendingRewards;
}
/*///////////////////////////////////////////////////////////////
EVENTS
///////////////////////////////////////////////////////////////*/
/**
* @notice Emitted when the user stakes tokens
* @param _user The user that staked the tokens
* @param _index The index of the deposit
* @param _amount The amount of tokens staked
* @param _lockupPeriod The lockup period
* @param _unlockAt The timestamp when the tokens can be withdrawn
*/
event Staked(
address indexed _user, uint256 indexed _index, uint256 _amount, uint256 _lockupPeriod, uint256 _unlockAt
);
/**
* @notice Emitted when the user stakes again an unlocked deposit
* @param _user The user that staked the tokens
* @param _index The index of the deposit
* @param _amount The amount of tokens staked
* @param _lockupPeriod The lockup period
* @param _unlockAt The timestamp when the tokens can be withdrawn
*/
event StakedUnlocked(
address indexed _user, uint256 indexed _index, uint256 _amount, uint256 _lockupPeriod, uint256 _unlockAt
);
/**
* @notice Emitted when the user adds tokens to an existing stake
* @param _user The user that staked the tokens
* @param _index The index of the deposit
* @param _amount The amount of tokens added
*/
event StakeIncreased(address indexed _user, uint256 indexed _index, uint256 _amount);
/**
* @notice Emitted when the user claims pending rewards and creates a new deposit
* @param _user The user that staked the rewards
* @param _index The index of the created stake
* @param _amount The amount of tokens staked
* @param _lockupPeriod The lockup period
*/
event ClaimRewardAndStake(address indexed _user, uint256 indexed _index, uint256 _amount, uint256 _lockupPeriod);
/**
* @notice Emitted when the user claims pending rewards and adds the tokens to an existing stake
* @param _user The user that staked the tokens
* @param _index The index of the deposit
* @param _amount The amount of tokens added
*/
event ClaimRewardAndIncreaseStake(address indexed _user, uint256 indexed _index, uint256 _amount);
/**
* @notice Emitted when the user initiates a withdrawal
* @param _user The user that initiated the withdrawal
* @param _index The index of the deposit
* @param _withdrawAt The end of the withdrawal period
*/
event WithdrawalInitiated(address indexed _user, uint256 indexed _index, uint256 _withdrawAt);
/**
* @notice Emitted when the user cancels the withdrawal
* @param _user The user that cancelled the withdrawal
* @param _index The index of the deposit
*/
event WithdrawalCancelled(address indexed _user, uint256 indexed _index);
/**
* @notice Emitted when the user withdraws tokens
* @param _user The user that withdrew the tokens
* @param _index The index of the deposit
* @param _amount The amount of tokens withdrawn
*/
event Withdrawn(address indexed _user, uint256 indexed _index, uint256 _amount);
/**
* @notice Emitted when the user claims their rewards
* @param _user The user that claimed the rewards
* @param _amount The amount of rewards claimed
*/
event RewardPaid(address indexed _user, uint256 _amount);
/**
* @notice Emitted when the reward amount is added
* @param _reward The new reward amount
*/
event RewardAdded(uint256 _reward);
/**
* @notice Emitted when the rewards duration is updated
* @param _oldRewardsDuration The previous rewards duration
* @param _rewardsDuration The new rewards duration
*/
event RewardsDurationUpdated(uint256 _oldRewardsDuration, uint256 _rewardsDuration);
/**
* @notice Emitted when the dust tokens are collected
* @param _owner The owner that collected the dust tokens
* @param _token The token address
* @param _amount The amount of tokens collected
*/
event DustCollected(address indexed _owner, IERC20 _token, uint256 _amount);
/**
* @notice Emitted when the staked deposits and the rewards are retracted by the owner
* @param _owner The owner that withdrew the tokens
* @param _amount The amount of tokens retracted
*/
event EmergencyWithdrawn(address indexed _owner, uint256 _amount);
/**
* @notice Emitted when the withdrawal period is updated
* @param _oldWithdrawalPeriod The previous withdrawal period
* @param _withdrawalPeriod The new withdrawal period
*/
event WithdrawalPeriodUpdated(uint256 _oldWithdrawalPeriod, uint256 _withdrawalPeriod);
/**
* @notice Emitted when the distributor address is updated
* @param _oldDistributor The previous distributor
* @param _distributor The new distributor
*/
event DistributorUpdated(IDistributor _oldDistributor, IDistributor _distributor);
/*///////////////////////////////////////////////////////////////
ERRORS
///////////////////////////////////////////////////////////////*/
/**
* @notice Throws if the provided amount is zero
*/
error ZeroAmount();
/**
* @notice Throws if the provided weight is zero
*/
error ZeroWeight();
/**
* @notice Throws if the deposit with the given index does not exist
*/
error InvalidDepositIndex();
/**
* @notice Throws if trying to withdraw a locked deposit
*/
error DepositLocked();
/**
* @notice Throws if the lockup period is invalid
*/
error InvalidLockupPeriod();
/**
* @notice Throws if the staking contract has insufficient balance to pay the rewards at the given rate
*/
error InsufficientBalance();
/**
* @notice Throws if the period is not finished
*/
error PeriodNotFinished();
/**
* @notice Throws if the token is invalid
*/
error InvalidToken();
/**
* @notice Throws if the caller is not the distributor
*/
error OnlyDistributor();
/**
* @notice Throws if the caller is trying to add tokens to a locked deposit
*/
error CannotIncreaseLockedStake();
/**
* @notice Throws if the withdrawal is not initiated while trying to withdraw
*/
error WithdrawalNotInitiated();
/**
* @notice Throws if the caller is trying to initiate a withdrawal of a deposit that's already in the withdrawal process
*/
error WithdrawalAlreadyInitiated();
/**
* @notice Throws if the withdrawal period is not over while trying to withdraw
*/
error DepositNotWithdrawable();
/*///////////////////////////////////////////////////////////////
VARIABLES
///////////////////////////////////////////////////////////////*/
/**
* @notice The address of the token contract
* @return _token The token contract
*/
function token() external view returns (IERC20 _token);
/**
* @notice The address of the distributor contract
* @return _distributor The distributor contract
*/
function distributor() external view returns (IDistributor _distributor);
/**
* @notice The time period in seconds over which rewards are distributed
* @return _rewardsDuration The rewards duration
*/
function rewardsDuration() external view returns (uint256 _rewardsDuration);
/**
* @notice Returns the timestamp of the last block at which the rewards will be distributed
* @return _periodFinish The end of the rewards period
*/
function periodFinish() external view returns (uint256 _periodFinish);
/**
* @notice The amount of rewards given to the stakers every second
* @return _rewardPerSecond The amount of reward per second
*/
function rewardPerSecond() external view returns (uint256 _rewardPerSecond);
/**
* @notice The time the reward per second was updated
* @return _lastUpdateTime The last time the reward per second was updated
*/
function lastUpdateTime() external view returns (uint256 _lastUpdateTime);
/**
* @notice The total weight of the deposits in the contract
* @return _totalWeights The total weight of the deposits
*/
function totalWeights() external view returns (uint256 _totalWeights);
/**
* @notice The total amount of tokens staked in the contract
* @return _totalDeposits The amount of tokens staked in the contract
*/
function totalDeposits() external view returns (uint256 _totalDeposits);
/**
* @notice The amount of tokens intended to be distributed as rewards
* @return _totalRewards The total reward amount
*/
function totalRewards() external view returns (uint256 _totalRewards);
/**
* @notice The reward generated per staker's share of the pool
* @return _rewardPerShare The reward per share
*/
function rewardPerShare() external view returns (uint256 _rewardPerShare);
/**
* @notice The time period in seconds after which the staker can withdraw their tokens
* @dev This is only needed for non-lockup deposits
* @return _withdrawalPeriod The withdrawal period
*/
function withdrawalPeriod() external view returns (uint256 _withdrawalPeriod);
/**
* @notice Provides information about a given staker
* @param _user The staker's address
* @return _weight The total weight of the staker's deposits
* @return _depositCount The number of deposits the staker has
* @return _rewardPerShareSnapshot The amount of rewards per share as seen at the last update
* @return _pendingRewards The amount of rewards pending to be claimed by the staker
*/
function stakers(address _user)
external
view
returns (uint128 _weight, uint128 _depositCount, uint128 _rewardPerShareSnapshot, uint128 _pendingRewards);
/**
* @notice Returns a user's deposit with the given index
* @param _user The address of the user
* @param _depositIndex The index of the deposit
* @return _amount The amount of tokens deposited
* @return _unlockAt The timestamp when the tokens can be withdrawn
* @return _lockupPeriod The period the tokens are locked to get the bonus
* @return _index The index of the deposit
*/
function deposits(
address _user,
uint256 _depositIndex
) external view returns (uint128 _amount, uint40 _unlockAt, uint32 _lockupPeriod, uint16 _index, uint40 _withdrawAt);
/*///////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
///////////////////////////////////////////////////////////////*/
/**
* @notice The list of deposits of the user
* @param _user The address of the user
* @param _startFrom The index to start from
* @param _batchSize The size of the batch
* @return _list The list of deposits
*/
function listDeposits(
address _user,
uint256 _startFrom,
uint256 _batchSize
) external view returns (Deposit[] memory _list);
/**
* @notice Calculates APY based on the given amount and the lockup period
* @param _amount The amount of tokens to stake
* @param _lockupPeriod The lockup period
* @return _apy The APY the staker would get
*/
function calculateAPY(uint256 _amount, uint256 _lockupPeriod) external view returns (uint256 _apy);
/**
* @notice Returns the APY of an existing deposit
* @param _user The staker address
* @param _index The index of the deposit
* @return _apy The APY the deposit is generating
*/
function calculateAPY(address _user, uint256 _index) external view returns (uint256 _apy);
/**
* @notice The amount of pending rewards the staker has
* @param _user The address of the user
* @return _pendingRewards The amount of the rewards ready to be claimed
*/
function pendingRewards(address _user) external view returns (uint256 _pendingRewards);
/**
* @notice The stake function
* @param _amount The amount of tokens
* @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
*/
function stake(uint256 _amount, uint256 _lockupPeriod) external;
/**
* @notice The stake function for the distributor, allowing to stake on behalf of another address
* @param _amount The amount of tokens
* @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
* @param _user The address of the user to stake for
*/
function stake(uint256 _amount, uint256 _lockupPeriod, address _user) external;
/**
* @notice Add the provided amount of tokens to an existing stake
* @param _amount The amount of tokens to add
* @param _index The index of the deposit to increase
*/
function increaseStake(uint256 _index, uint256 _amount) external;
/**
* @notice Stakes the unlocked deposit with a higher lockup period
* @param _index The index of the deposit
* @param _newLockupPeriod The new lockup period
*/
function stakeUnlocked(uint256 _index, uint256 _newLockupPeriod) external;
/**
* @notice Claims pending rewards and adds them to an existing stake
* @param _index The index of the deposit to increase
*/
function getRewardAndIncreaseStake(uint256 _index) external;
/**
* @notice Initiates a withdrawal of the deposit
* @dev The tokens will be locked for the withdrawal period
* @dev Only needed for non-lockup deposits
* @param _index The index of the deposit to withdraw
*/
function initiateWithdrawal(uint256 _index) external;
/**
* @notice Cancels the withdrawal of the deposit
* @param _index The index of the deposit to cancel the withdrawal
*/
function cancelWithdrawal(uint256 _index) external;
/**
* @notice The withdraw function
* @param _index The index of the deposit to withdraw
*/
function withdraw(uint256 _index) external;
/**
* @notice Transfers pending rewards to the caller
*/
function getReward() external;
/**
* @notice Claims the pending rewards and creates an unlocked deposit from them
* @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
*/
function getRewardAndStake(uint256 _lockupPeriod) external;
/**
* @notice Updates the total amount of rewards for the stakers
* @param _reward The new reward amount
*/
function setRewardAmount(uint256 _reward) external;
/**
* @notice Updates the rewards duration
* @param _rewardsDuration The new rewards duration
*/
function setRewardsDuration(uint256 _rewardsDuration) external;
/**
* @notice Updates the distributor address
* @param _distributor The new distributor
*/
function setDistributorAddress(IDistributor _distributor) external;
/**
* @notice Sends any dust tokens to the owner
* @param _token The token address
* @param _amount The amount of tokens to withdraw
*/
function collectDust(IERC20 _token, uint256 _amount) external;
/**
* @notice An emergency function which sends the specified number of tokens to the owner
* @param _amount The amount of tokens to withdraw
*/
function emergencyWithdraw(uint256 _amount) external;
/**
* @notice Updates the withdrawal period
* @param _withdrawalPeriod The new withdrawal period
*/
function setWithdrawalPeriod(uint256 _withdrawalPeriod) external;
/**
* @notice Pauses the staking and withdrawals
*/
function pause() external;
/**
* @notice Unpauses the staking and withdrawals
*/
function unpause() external;
}// 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) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC1967-compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
}// 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) (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) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// 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) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}{
"remappings": [
"ds-test/=node_modules/ds-test/src/",
"forge-std/=node_modules/forge-std/src/",
"openzeppelin/=node_modules/@openzeppelin/contracts/",
"openzeppelin-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
"contracts/=src/contracts/",
"interfaces/=src/interfaces/",
"@openzeppelin/=node_modules/@openzeppelin/",
"openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/"
],
"optimizer": {
"enabled": true,
"runs": 10000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"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":[],"name":"CannotIncreaseLockedStake","type":"error"},{"inputs":[],"name":"DepositLocked","type":"error"},{"inputs":[],"name":"DepositNotWithdrawable","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidDepositIndex","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLockupPeriod","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OnlyDistributor","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":"PeriodNotFinished","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"WithdrawalAlreadyInitiated","type":"error"},{"inputs":[],"name":"WithdrawalNotInitiated","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"inputs":[],"name":"ZeroWeight","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ClaimRewardAndIncreaseStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"ClaimRewardAndStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IDistributor","name":"_oldDistributor","type":"address"},{"indexed":false,"internalType":"contract IDistributor","name":"_distributor","type":"address"}],"name":"DistributorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"DustCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"EmergencyWithdrawn","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":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldRewardsDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"StakeIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lockupPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_unlockAt","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lockupPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_unlockAt","type":"uint256"}],"name":"StakedUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"}],"name":"WithdrawalCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_withdrawAt","type":"uint256"}],"name":"WithdrawalInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldWithdrawalPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_withdrawalPeriod","type":"uint256"}],"name":"WithdrawalPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"calculateAPY","outputs":[{"internalType":"uint256","name":"_apy","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"calculateAPY","outputs":[{"internalType":"uint256","name":"_apy","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"cancelWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"collectDust","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"deposits","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint40","name":"unlockAt","type":"uint40"},{"internalType":"uint32","name":"lockupPeriod","type":"uint32"},{"internalType":"uint16","name":"index","type":"uint16"},{"internalType":"uint40","name":"withdrawAt","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"contract IDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getRewardAndIncreaseStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"getRewardAndStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"increaseStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDistributor","name":"_distributor","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"initiateWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_startFrom","type":"uint256"},{"internalType":"uint256","name":"_batchSize","type":"uint256"}],"name":"listDeposits","outputs":[{"components":[{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint40","name":"unlockAt","type":"uint40"},{"internalType":"uint32","name":"lockupPeriod","type":"uint32"},{"internalType":"uint16","name":"index","type":"uint16"},{"internalType":"uint40","name":"withdrawAt","type":"uint40"}],"internalType":"struct IStaking.Deposit[]","name":"_list","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"_pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IDistributor","name":"_distributor","type":"address"}],"name":"setDistributorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"setRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawalPeriod","type":"uint256"}],"name":"setWithdrawalPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_newLockupPeriod","type":"uint256"}],"name":"stakeUnlocked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint128","name":"weight","type":"uint128"},{"internalType":"uint128","name":"depositCount","type":"uint128"},{"internalType":"uint128","name":"rewardPerShareSnapshot","type":"uint128"},{"internalType":"uint128","name":"pendingRewards","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a06040523060805234801562000014575f80fd5b506200001f62000025565b620000d9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000765760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d65780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b608051614022620001005f395f8181612e7d01528181612ea6015261307401526140225ff3fe6080604052600436106102e2575f3560e01c80638456cb5911610186578063bca7093d116100dc578063d6d6817711610087578063ebe2b12b11610062578063ebe2b12b14610957578063f2fde38b1461096c578063fc0c546a1461098b575f80fd5b8063d6d681771461080d578063da10d9e214610924578063e30c397814610943575f80fd5b8063c0c53b8b116100b7578063c0c53b8b146107ba578063c8f33c91146107d9578063cc1a378f146107ee575f80fd5b8063bca7093d14610767578063bec10cde1461077c578063bfe109281461079b575f80fd5b8063926323d51161013c578063ad3cb1cc11610117578063ad3cb1cc146106d4578063b14b990f14610729578063b873995a14610748575f80fd5b8063926323d514610681578063973b294f14610696578063a8a65a78146106b5575f80fd5b80638da5cb5b1161016c5780638da5cb5b1461059c5780638f10369a146105c85780639168ae72146105dd575f80fd5b80638456cb591461056957806387950f491461057d575f80fd5b8063446a2ec81161023b578063715018a6116101f157806379ba5097116101cc57806379ba5097146105215780637b0472f0146105355780637d88209714610554575f80fd5b8063715018a6146104cf5780637628a37d146104e357806376c66d0214610502575f80fd5b806352d1902d1161022157806352d1902d1461045b5780635312ea8e1461046f5780635c975abb1461048e575f80fd5b8063446a2ec8146104335780634f1ef28614610448575f80fd5b806331d7a2621161029b5780633d18b912116102765780633d18b912146103ec5780633efcfda4146104005780633f4ba83a1461041f575f80fd5b806331d7a2621461038c578063386a9525146103ab57806339c35fae146103c0575f80fd5b80631fdc9dba116102cb5780631fdc9dba1461032f57806320a0b9ae1461034e5780632e1a7d4d1461036d575f80fd5b80630e15561a146102e657806312edde5e1461030e575b5f80fd5b3480156102f1575f80fd5b506102fb60075481565b6040519081526020015b60405180910390f35b348015610319575f80fd5b5061032d610328366004613a9e565b6109a9565b005b34801561033a575f80fd5b5061032d610349366004613ab5565b610c2c565b348015610359575f80fd5b506102fb610368366004613ae9565b610ec9565b348015610378575f80fd5b5061032d610387366004613a9e565b611019565b348015610397575f80fd5b506102fb6103a6366004613b13565b6112ef565b3480156103b6575f80fd5b506102fb60025481565b3480156103cb575f80fd5b506103df6103da366004613b2e565b6113ab565b6040516103059190613b60565b3480156103f7575f80fd5b5061032d6115d8565b34801561040b575f80fd5b5061032d61041a366004613a9e565b611699565b34801561042a575f80fd5b5061032d611840565b34801561043e575f80fd5b506102fb60065481565b61032d610456366004613c20565b611852565b348015610466575f80fd5b506102fb61186d565b34801561047a575f80fd5b5061032d610489366004613a9e565b61189b565b348015610499575f80fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff166040519015158152602001610305565b3480156104da575f80fd5b5061032d6119df565b3480156104ee575f80fd5b5061032d6104fd366004613cfc565b6119f0565b34801561050d575f80fd5b5061032d61051c366004613a9e565b611ac8565b34801561052c575f80fd5b5061032d611b8d565b348015610540575f80fd5b5061032d61054f366004613ab5565b611bf3565b34801561055f575f80fd5b506102fb60085481565b348015610574575f80fd5b5061032d611c8e565b348015610588575f80fd5b5061032d610597366004613b13565b611c9e565b3480156105a7575f80fd5b506105b0611d20565b6040516001600160a01b039091168152602001610305565b3480156105d3575f80fd5b506102fb60055481565b3480156105e8575f80fd5b506106456105f7366004613b13565b600b6020525f9081526040902080546001909101546fffffffffffffffffffffffffffffffff8083169270010000000000000000000000000000000090819004821692808316929190041684565b604080516fffffffffffffffffffffffffffffffff95861681529385166020850152918416918301919091529091166060820152608001610305565b34801561068c575f80fd5b506102fb60095481565b3480156106a1575f80fd5b5061032d6106b0366004613a9e565b611d54565b3480156106c0575f80fd5b5061032d6106cf366004613a9e565b611d9a565b3480156106df575f80fd5b5061071c6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516103059190613d54565b348015610734575f80fd5b5061032d610743366004613ae9565b611f41565b348015610753575f80fd5b506102fb610762366004613ab5565b61203d565b348015610772575f80fd5b506102fb600a5481565b348015610787575f80fd5b5061032d610796366004613ab5565b61209c565b3480156107a6575f80fd5b506001546105b0906001600160a01b031681565b3480156107c5575f80fd5b5061032d6107d4366004613da4565b6120f5565b3480156107e4575f80fd5b506102fb60045481565b3480156107f9575f80fd5b5061032d610808366004613a9e565b6122eb565b348015610818575f80fd5b506108d6610827366004613ae9565b600c60209081525f92835260408084209091529082529020546fffffffffffffffffffffffffffffffff81169064ffffffffff700100000000000000000000000000000000820481169163ffffffff75010000000000000000000000000000000000000000008204169161ffff790100000000000000000000000000000000000000000000000000830416917b0100000000000000000000000000000000000000000000000000000090041685565b604080516fffffffffffffffffffffffffffffffff909616865264ffffffffff948516602087015263ffffffff9093169285019290925261ffff16606084015216608082015260a001610305565b34801561092f575f80fd5b5061032d61093e366004613a9e565b61236d565b34801561094e575f80fd5b506105b0612422565b348015610962575f80fd5b506102fb60035481565b348015610977575f80fd5b5061032d610986366004613b13565b61244a565b348015610996575f80fd5b505f546105b0906001600160a01b031681565b335f908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff9091169003610a12576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff1615610a6a576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff1615610ac9576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825282546fffffffffffffffffffffffffffffffff8116825264ffffffffff70010000000000000000000000000000000082048116602084015263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049091166080820152610b87906124e7565b610b9d600a5442610b989190613e0e565b6125d6565b81547affffffffffffffffffffffffffffffffffffffffffffffffffffff167b0100000000000000000000000000000000000000000000000000000064ffffffffff9283168102919091178084556040519190049091168152829033907f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401906020015b60405180910390a35050565b335f908152600c602090815260408083208584528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b01000000000000000000000000000000000000000000000000000000900490921660808301529091819003610d36576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42826020015164ffffffffff161115610d7b576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b608082015164ffffffffff1615610dbe576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82826040015163ffffffff1610610e01576040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e0a826124e7565b335f908152600c60209081526040808320878452909152812081905560088054839290610e38908490613e21565b909155505f9050610e4a828533612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f253ddc1867b794a16a085d3710f208ac9062fbbfe498fb9d0b67c5824062ebb0910160405180910390a35050505050565b6001600160a01b0382165f908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff750100000000000000000000000000000000000000000083041693830184905261ffff79010000000000000000000000000000000000000000000000000083041660608401527b010000000000000000000000000000000000000000000000000000009091049093166080820152918391610fad916129bc565b90505f670de0b6b3a76400006301da9c00600554610fcb9190613e34565b610fd59190613e34565b610fe0906064613e34565b905061100f8282600954865f01516fffffffffffffffffffffffffffffffff1661100a9190613e34565b612a7b565b9695505050505050565b335f908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049092166080830152909103611121576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604081015163ffffffff16156111845742816020015164ffffffffff161115611176576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61117f816124e7565b611234565b600a5415801561119d5750608081015164ffffffffff16155b156111ab5761117f816124e7565b42816080015164ffffffffff1611156111f0576040517f87fb75bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015164ffffffffff165f03611234576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f01516fffffffffffffffffffffffffffffffff1660085f82825461125a9190613e21565b9091555050335f818152600c602090815260408083208684529091528120819055825190546112a6926001600160a01b03909116916fffffffffffffffffffffffffffffffff16612b72565b80516040516fffffffffffffffffffffffffffffffff9091168152829033907f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc690602001610c20565b6001600160a01b0381165f908152600b60205260408120600181015482906fffffffffffffffffffffffffffffffff16611327612be6565b6113319190613e21565b82549091505f90670de0b6b3a76400009061135f9084906fffffffffffffffffffffffffffffffff16613e34565b6113699190613e78565b60018401549091506113a290829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16613e0e565b95945050505050565b6001600160a01b0383165f908152600b602052604090205460609070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16808411156113fa57506115d1565b6114048482613e21565b831115611418576114158482613e21565b92505b8267ffffffffffffffff81111561143157611431613bf3565b6040519080825280602002602001820160405280156114a757816020015b6040805160a0810182525f808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161144f5790505b5091505f5b838110156115ce576001600160a01b0386165f908152600c60205260408120906114d68388613e0e565b815260208082019290925260409081015f20815160a08101835290546fffffffffffffffffffffffffffffffff8116825264ffffffffff700100000000000000000000000000000000820481169483019490945263ffffffff75010000000000000000000000000000000000000000008204169282019290925261ffff79010000000000000000000000000000000000000000000000000083041660608201527b01000000000000000000000000000000000000000000000000000000909104909116608082015283518490839081106115b2576115b2613eb0565b6020026020010181905250806115c790613edd565b90506114ac565b50505b9392505050565b5f6115e233612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611695576001820180546fffffffffffffffffffffffffffffffff169055600780548291905f90611644908490613e21565b90915550505f5461165f906001600160a01b03163383612b72565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b335f908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff90911690819003611704576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547b01000000000000000000000000000000000000000000000000000000900464ffffffffff165f03611764576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61176e33612c50565b90505f61177b5f846129bc565b90508060095f82825461178e9190613e0e565b9091555061179d905081612d42565b825483905f906117c09084906fffffffffffffffffffffffffffffffff16613f14565b82546fffffffffffffffffffffffffffffffff9182166101009390930a92830291909202199091161790555083547affffffffffffffffffffffffffffffffffffffffffffffffffffff168455604051859033907f2eed97477f07c07ec48f8f678f4e84f7c0de55bf33f51c3dc989b13353080319905f90a35050505050565b611848612d97565b611850612de2565b565b61185a612e72565b61186382612f42565b6116958282612f4a565b5f611876613069565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6118a3612d97565b805f036118dc576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561193b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061195f9190613f44565b90505f81831161196f5782611971565b815b905061199061197e611d20565b5f546001600160a01b03169083612b72565b611998611d20565b6001600160a01b03167f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e51826040516119d291815260200190565b60405180910390a2505050565b6119e7612d97565b6118505f6130cb565b6001546001600160a01b03163314611a34576040517f1b8f6df300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611a40848484612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff16916001600160a01b038516917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f4091015b60405180910390a350505050565b5f611ad233612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611b88576001820180546fffffffffffffffffffffffffffffffff1690555f611b2c828533612624565b90508160075f828254611b3f9190613e21565b90915550506060810151604080518481526020810187905261ffff9092169133917f28a4391b81854dd0b9a033088421ef92664cbb2ce533b69baa569d4d1b81b3839101611aba565b505050565b3380611b97612422565b6001600160a01b031614611be7576040517f118cdaa70000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024015b60405180910390fd5b611bf0816130cb565b50565b5f611bff838333612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f40910160405180910390a35f54611b88906001600160a01b031633308661311b565b611c96612d97565b61185061315a565b611ca6612d97565b600180546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f111a961d91cf441fe07e7bfddc128b30ab56974d1a76851e969e0642fdb2dd5091015b60405180910390a15050565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b611d5c612d97565b600a80549082905560408051828152602081018490527f759d29a964e1aa0e3273a781eec37e160daa40a40342ad659d83028dd14aacd19101611d14565b611da2612d97565b5f80546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611e01573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e259190613f44565b905060075460085482611e389190613e21565b611e429190613e21565b821115611e7b576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e845f612c50565b506003544210611ea357600254611e9b9083613e78565b600555611ee3565b5f42600354611eb29190613e21565b90505f60055482611ec39190613e34565b600254909150611ed38286613e0e565b611edd9190613e78565b60055550505b426004819055600254611ef591613e0e565b6003819055508160075f828254611f0c9190613e0e565b90915550506040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d90602001611d14565b611f49612d97565b5f546001600160a01b0383811691161480611f6b57506001600160a01b038216155b15611fa2576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03611fdb576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611fe4611d20565b9050611ffa6001600160a01b0384168284612b72565b604080516001600160a01b038581168252602082018590528316917f4b3832ed948bc80ab35e8cab3a5923e6e1a57696d02c846a8b6f54d39bf9acf091016119d2565b5f8061204983856129bc565b90505f670de0b6b3a76400006301da9c006005546120679190613e34565b6120719190613e34565b61207c906064613e34565b90506113a2828287856009546120929190613e0e565b61100a9190613e34565b6120a78282336131d3565b604051818152829033907fe6afb5ca7cc84435baf09da39fcb42fc0fb8bdfef6c3ff2ce9fce2c70a18f8219060200160405180910390a35f54611695906001600160a01b031633308461311b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f8115801561213f5750825b90505f8267ffffffffffffffff16600114801561215b5750303b155b905081158015612169575080155b156121a0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156122015784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b5f80546001600160a01b03808b167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560018054928a16929091169190911790556309450c0060025562093a80600a556122608661340f565b612268613420565b612270613420565b612278613428565b61228061315a565b83156122e15784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6122f3612d97565b42600354111561232f576040517f449a6ba000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280549082905560408051828152602081018490527fd20a04eb2807bde8cbdf16ef27a46d94a3162d81818f1781c0fe4ed9194ca3919101611d14565b5f61237733612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611b88576001820180546fffffffffffffffffffffffffffffffff1690556123d08382336131d3565b8060075f8282546123e19190613e21565b9091555050604051818152839033907fbcb84e4496de59b7cc314368190ec54380f616d6535422e388531cc05ba1b8829060200160405180910390a3505050565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00611d44565b612452612d97565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03831690811782556124ae611d20565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b5f6124f133612c50565b90505f61251d836040015163ffffffff16845f01516fffffffffffffffffffffffffffffffff166129bc565b82549091506fffffffffffffffffffffffffffffffff168111156125545781546fffffffffffffffffffffffffffffffff16612556565b805b90508060095f8282546125699190613e21565b90915550612578905081612d42565b825483905f9061259b9084906fffffffffffffffffffffffffffffffff16613f5b565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050565b5f64ffffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526028600482015260248101839052604401611bde565b5090565b6040805160a0810182525f80825260208201819052918101829052606081018290526080810191909152835f03612687576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61269183612c50565b90505f61269e85876129bc565b9050805f036126d9576040517f19a2a9bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060095f8282546126ea9190613e0e565b925050819055508560085f8282546127029190613e0e565b90915550612711905081612d42565b825483905f906127349084906fffffffffffffffffffffffffffffffff16613f14565b82546101009290920a6fffffffffffffffffffffffffffffffff81810219909316918316021790915583545f925070010000000000000000000000000000000090041683601061278383613f84565b91906101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506fffffffffffffffffffffffffffffffff1690505f86426127da9190613e0e565b90506040518060a001604052806127f08a612d42565b6fffffffffffffffffffffffffffffffff168152602001612810836125d6565b64ffffffffff16815260200161282589613438565b63ffffffff16815260200161283984613481565b61ffff90811682525f60209283018190526001600160a01b039099168952600c82526040808a20958a52948252978490208251815492840151958401516060850151608086015164ffffffffff9081167b01000000000000000000000000000000000000000000000000000000027affffffffffffffffffffffffffffffffffffffffffffffffffffff92909d16790100000000000000000000000000000000000000000000000000027fffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff909416750100000000000000000000000000000000000000000002939093167fffffffffff000000000000ffffffffffffffffffffffffffffffffffffffffff99909116700100000000000000000000000000000000027fffffffffffffffffffffff0000000000000000000000000000000000000000009096166fffffffffffffffffffffffffffffffff90941693909317949094179690961617949094171696909617909155509295945050505050565b5f825f036129e3576103e86129d28360fa613e34565b6129dc9190613e78565b9050612a75565b6301da9c0083036129fd576103e86129d2836101f4613e34565b6302c7ea008303612a17576103e86129d283610271613e34565b6303b538008303612a31576103e86129d2836102ee613e34565b63058fd4008303612a43575080612a75565b6040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612ace57838281612ac457612ac4613e4b565b04925050506115d1565b808411612b07576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6040516001600160a01b03838116602483015260448201839052611b8891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134c8565b5f6009545f03612bf7575060065490565b5f600454612c03613542565b612c0d9190613e21565b9050600954670de0b6b3a764000060055483612c299190613e34565b612c339190613e34565b612c3d9190613e78565b600654612c4a9190613e0e565b91505090565b5f612c59613558565b5f612c62612be6565b9050801580612c72575060065481115b15612c88576006819055612c84613542565b6004555b6001600160a01b0383165f818152600b60205260409020925015612d3c57612cb7612cb2846112ef565b612d42565b6001830180546fffffffffffffffffffffffffffffffff928316700100000000000000000000000000000000029216919091179055600654612cf890612d42565b6001830180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790555b50919050565b5f6fffffffffffffffffffffffffffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401611bde565b33612da0611d20565b6001600160a01b031614611850576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611bde565b612dea6135b4565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480612f0b57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612eff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611850576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bf0612d97565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612fc2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612fbf91810190613f44565b60015b613003576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611bde565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc811461305f576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611bde565b611b88838361360f565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611850576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815561169582613664565b6040516001600160a01b0384811660248301528381166044830152606482018390526131549186918216906323b872dd90608401612b9f565b50505050565b613162613558565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833612e54565b6001600160a01b0381165f908152600c602090815260408083208684529091528120805490916fffffffffffffffffffffffffffffffff9091169003613245576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff161561329c576040517ee24fbd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff16156132fb576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6133065f856129bc565b90505f61331284612c50565b90508160095f8282546133259190613e0e565b925050819055508460085f82825461333d9190613e0e565b9091555061334c905082612d42565b815482905f9061336f9084906fffffffffffffffffffffffffffffffff16613f14565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506133ae85612d42565b835484905f906133d19084906fffffffffffffffffffffffffffffffff16613f14565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050505050565b6134176136ec565b611bf081613753565b6118506136ec565b6134306136ec565b61185061379d565b5f63ffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526020600482015260248101839052604401611bde565b5f61ffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526010600482015260248101839052604401611bde565b5f6134dc6001600160a01b038416836137ee565b905080515f141580156135005750808060200190518101906134fe9190613fb2565b155b15611b88576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611bde565b5f6003544210613553575060035490565b504290565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611850576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611850576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613618826137fb565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561365c57611b8882826138a2565b61169561390b565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611850576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61375b6136ec565b6001600160a01b038116611be7576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f6004820152602401611bde565b6137a56136ec565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60606115d183835f613943565b806001600160a01b03163b5f03613849576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611bde565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516138be9190613fd1565b5f60405180830381855af49150503d805f81146138f6576040519150601f19603f3d011682016040523d82523d5f602084013e6138fb565b606091505b50915091506113a28583836139e7565b3415611850576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015613981576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611bde565b5f80856001600160a01b0316848660405161399c9190613fd1565b5f6040518083038185875af1925050503d805f81146139d6576040519150601f19603f3d011682016040523d82523d5f602084013e6139db565b606091505b509150915061100f8683835b6060826139fc576139f782613a5c565b6115d1565b8151158015613a1357506001600160a01b0384163b155b15613a55576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611bde565b50806115d1565b805115613a6c5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60208284031215613aae575f80fd5b5035919050565b5f8060408385031215613ac6575f80fd5b50508035926020909101359150565b6001600160a01b0381168114611bf0575f80fd5b5f8060408385031215613afa575f80fd5b8235613b0581613ad5565b946020939093013593505050565b5f60208284031215613b23575f80fd5b81356115d181613ad5565b5f805f60608486031215613b40575f80fd5b8335613b4b81613ad5565b95602085013595506040909401359392505050565b602080825282518282018190525f919060409081850190868401855b82811015613be657815180516fffffffffffffffffffffffffffffffff1685528681015164ffffffffff908116888701528682015163ffffffff168787015260608083015161ffff1690870152608091820151169085015260a09093019290850190600101613b7c565b5091979650505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f8060408385031215613c31575f80fd5b8235613c3c81613ad5565b9150602083013567ffffffffffffffff80821115613c58575f80fd5b818501915085601f830112613c6b575f80fd5b813581811115613c7d57613c7d613bf3565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613cc357613cc3613bf3565b81604052828152886020848701011115613cdb575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f805f60608486031215613d0e575f80fd5b83359250602084013591506040840135613d2781613ad5565b809150509250925092565b5f5b83811015613d4c578181015183820152602001613d34565b50505f910152565b602081525f8251806020840152613d72816040850160208701613d32565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b5f805f60608486031215613db6575f80fd5b8335613dc181613ad5565b92506020840135613dd181613ad5565b91506040840135613d2781613ad5565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b80820180821115612a7557612a75613de1565b81810381811115612a7557612a75613de1565b8082028115828204841417612a7557612a75613de1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82613eab577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f0d57613f0d613de1565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115613f3d57613f3d613de1565b5092915050565b5f60208284031215613f54575f80fd5b5051919050565b6fffffffffffffffffffffffffffffffff828116828216039080821115613f3d57613f3d613de1565b5f6fffffffffffffffffffffffffffffffff808316818103613fa857613fa8613de1565b6001019392505050565b5f60208284031215613fc2575f80fd5b815180151581146115d1575f80fd5b5f8251613fe2818460208701613d32565b919091019291505056fea2646970667358221220508c51a3578a5963e55424d006f02b4318886b7763c9dc932b1f4b42402ee01564736f6c63430008170033
Deployed Bytecode
0x6080604052600436106102e2575f3560e01c80638456cb5911610186578063bca7093d116100dc578063d6d6817711610087578063ebe2b12b11610062578063ebe2b12b14610957578063f2fde38b1461096c578063fc0c546a1461098b575f80fd5b8063d6d681771461080d578063da10d9e214610924578063e30c397814610943575f80fd5b8063c0c53b8b116100b7578063c0c53b8b146107ba578063c8f33c91146107d9578063cc1a378f146107ee575f80fd5b8063bca7093d14610767578063bec10cde1461077c578063bfe109281461079b575f80fd5b8063926323d51161013c578063ad3cb1cc11610117578063ad3cb1cc146106d4578063b14b990f14610729578063b873995a14610748575f80fd5b8063926323d514610681578063973b294f14610696578063a8a65a78146106b5575f80fd5b80638da5cb5b1161016c5780638da5cb5b1461059c5780638f10369a146105c85780639168ae72146105dd575f80fd5b80638456cb591461056957806387950f491461057d575f80fd5b8063446a2ec81161023b578063715018a6116101f157806379ba5097116101cc57806379ba5097146105215780637b0472f0146105355780637d88209714610554575f80fd5b8063715018a6146104cf5780637628a37d146104e357806376c66d0214610502575f80fd5b806352d1902d1161022157806352d1902d1461045b5780635312ea8e1461046f5780635c975abb1461048e575f80fd5b8063446a2ec8146104335780634f1ef28614610448575f80fd5b806331d7a2621161029b5780633d18b912116102765780633d18b912146103ec5780633efcfda4146104005780633f4ba83a1461041f575f80fd5b806331d7a2621461038c578063386a9525146103ab57806339c35fae146103c0575f80fd5b80631fdc9dba116102cb5780631fdc9dba1461032f57806320a0b9ae1461034e5780632e1a7d4d1461036d575f80fd5b80630e15561a146102e657806312edde5e1461030e575b5f80fd5b3480156102f1575f80fd5b506102fb60075481565b6040519081526020015b60405180910390f35b348015610319575f80fd5b5061032d610328366004613a9e565b6109a9565b005b34801561033a575f80fd5b5061032d610349366004613ab5565b610c2c565b348015610359575f80fd5b506102fb610368366004613ae9565b610ec9565b348015610378575f80fd5b5061032d610387366004613a9e565b611019565b348015610397575f80fd5b506102fb6103a6366004613b13565b6112ef565b3480156103b6575f80fd5b506102fb60025481565b3480156103cb575f80fd5b506103df6103da366004613b2e565b6113ab565b6040516103059190613b60565b3480156103f7575f80fd5b5061032d6115d8565b34801561040b575f80fd5b5061032d61041a366004613a9e565b611699565b34801561042a575f80fd5b5061032d611840565b34801561043e575f80fd5b506102fb60065481565b61032d610456366004613c20565b611852565b348015610466575f80fd5b506102fb61186d565b34801561047a575f80fd5b5061032d610489366004613a9e565b61189b565b348015610499575f80fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff166040519015158152602001610305565b3480156104da575f80fd5b5061032d6119df565b3480156104ee575f80fd5b5061032d6104fd366004613cfc565b6119f0565b34801561050d575f80fd5b5061032d61051c366004613a9e565b611ac8565b34801561052c575f80fd5b5061032d611b8d565b348015610540575f80fd5b5061032d61054f366004613ab5565b611bf3565b34801561055f575f80fd5b506102fb60085481565b348015610574575f80fd5b5061032d611c8e565b348015610588575f80fd5b5061032d610597366004613b13565b611c9e565b3480156105a7575f80fd5b506105b0611d20565b6040516001600160a01b039091168152602001610305565b3480156105d3575f80fd5b506102fb60055481565b3480156105e8575f80fd5b506106456105f7366004613b13565b600b6020525f9081526040902080546001909101546fffffffffffffffffffffffffffffffff8083169270010000000000000000000000000000000090819004821692808316929190041684565b604080516fffffffffffffffffffffffffffffffff95861681529385166020850152918416918301919091529091166060820152608001610305565b34801561068c575f80fd5b506102fb60095481565b3480156106a1575f80fd5b5061032d6106b0366004613a9e565b611d54565b3480156106c0575f80fd5b5061032d6106cf366004613a9e565b611d9a565b3480156106df575f80fd5b5061071c6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516103059190613d54565b348015610734575f80fd5b5061032d610743366004613ae9565b611f41565b348015610753575f80fd5b506102fb610762366004613ab5565b61203d565b348015610772575f80fd5b506102fb600a5481565b348015610787575f80fd5b5061032d610796366004613ab5565b61209c565b3480156107a6575f80fd5b506001546105b0906001600160a01b031681565b3480156107c5575f80fd5b5061032d6107d4366004613da4565b6120f5565b3480156107e4575f80fd5b506102fb60045481565b3480156107f9575f80fd5b5061032d610808366004613a9e565b6122eb565b348015610818575f80fd5b506108d6610827366004613ae9565b600c60209081525f92835260408084209091529082529020546fffffffffffffffffffffffffffffffff81169064ffffffffff700100000000000000000000000000000000820481169163ffffffff75010000000000000000000000000000000000000000008204169161ffff790100000000000000000000000000000000000000000000000000830416917b0100000000000000000000000000000000000000000000000000000090041685565b604080516fffffffffffffffffffffffffffffffff909616865264ffffffffff948516602087015263ffffffff9093169285019290925261ffff16606084015216608082015260a001610305565b34801561092f575f80fd5b5061032d61093e366004613a9e565b61236d565b34801561094e575f80fd5b506105b0612422565b348015610962575f80fd5b506102fb60035481565b348015610977575f80fd5b5061032d610986366004613b13565b61244a565b348015610996575f80fd5b505f546105b0906001600160a01b031681565b335f908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff9091169003610a12576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff1615610a6a576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff1615610ac9576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825282546fffffffffffffffffffffffffffffffff8116825264ffffffffff70010000000000000000000000000000000082048116602084015263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049091166080820152610b87906124e7565b610b9d600a5442610b989190613e0e565b6125d6565b81547affffffffffffffffffffffffffffffffffffffffffffffffffffff167b0100000000000000000000000000000000000000000000000000000064ffffffffff9283168102919091178084556040519190049091168152829033907f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401906020015b60405180910390a35050565b335f908152600c602090815260408083208584528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b01000000000000000000000000000000000000000000000000000000900490921660808301529091819003610d36576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42826020015164ffffffffff161115610d7b576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b608082015164ffffffffff1615610dbe576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82826040015163ffffffff1610610e01576040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e0a826124e7565b335f908152600c60209081526040808320878452909152812081905560088054839290610e38908490613e21565b909155505f9050610e4a828533612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f253ddc1867b794a16a085d3710f208ac9062fbbfe498fb9d0b67c5824062ebb0910160405180910390a35050505050565b6001600160a01b0382165f908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff750100000000000000000000000000000000000000000083041693830184905261ffff79010000000000000000000000000000000000000000000000000083041660608401527b010000000000000000000000000000000000000000000000000000009091049093166080820152918391610fad916129bc565b90505f670de0b6b3a76400006301da9c00600554610fcb9190613e34565b610fd59190613e34565b610fe0906064613e34565b905061100f8282600954865f01516fffffffffffffffffffffffffffffffff1661100a9190613e34565b612a7b565b9695505050505050565b335f908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049092166080830152909103611121576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604081015163ffffffff16156111845742816020015164ffffffffff161115611176576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61117f816124e7565b611234565b600a5415801561119d5750608081015164ffffffffff16155b156111ab5761117f816124e7565b42816080015164ffffffffff1611156111f0576040517f87fb75bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015164ffffffffff165f03611234576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f01516fffffffffffffffffffffffffffffffff1660085f82825461125a9190613e21565b9091555050335f818152600c602090815260408083208684529091528120819055825190546112a6926001600160a01b03909116916fffffffffffffffffffffffffffffffff16612b72565b80516040516fffffffffffffffffffffffffffffffff9091168152829033907f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc690602001610c20565b6001600160a01b0381165f908152600b60205260408120600181015482906fffffffffffffffffffffffffffffffff16611327612be6565b6113319190613e21565b82549091505f90670de0b6b3a76400009061135f9084906fffffffffffffffffffffffffffffffff16613e34565b6113699190613e78565b60018401549091506113a290829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16613e0e565b95945050505050565b6001600160a01b0383165f908152600b602052604090205460609070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16808411156113fa57506115d1565b6114048482613e21565b831115611418576114158482613e21565b92505b8267ffffffffffffffff81111561143157611431613bf3565b6040519080825280602002602001820160405280156114a757816020015b6040805160a0810182525f808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161144f5790505b5091505f5b838110156115ce576001600160a01b0386165f908152600c60205260408120906114d68388613e0e565b815260208082019290925260409081015f20815160a08101835290546fffffffffffffffffffffffffffffffff8116825264ffffffffff700100000000000000000000000000000000820481169483019490945263ffffffff75010000000000000000000000000000000000000000008204169282019290925261ffff79010000000000000000000000000000000000000000000000000083041660608201527b01000000000000000000000000000000000000000000000000000000909104909116608082015283518490839081106115b2576115b2613eb0565b6020026020010181905250806115c790613edd565b90506114ac565b50505b9392505050565b5f6115e233612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611695576001820180546fffffffffffffffffffffffffffffffff169055600780548291905f90611644908490613e21565b90915550505f5461165f906001600160a01b03163383612b72565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b335f908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff90911690819003611704576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547b01000000000000000000000000000000000000000000000000000000900464ffffffffff165f03611764576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61176e33612c50565b90505f61177b5f846129bc565b90508060095f82825461178e9190613e0e565b9091555061179d905081612d42565b825483905f906117c09084906fffffffffffffffffffffffffffffffff16613f14565b82546fffffffffffffffffffffffffffffffff9182166101009390930a92830291909202199091161790555083547affffffffffffffffffffffffffffffffffffffffffffffffffffff168455604051859033907f2eed97477f07c07ec48f8f678f4e84f7c0de55bf33f51c3dc989b13353080319905f90a35050505050565b611848612d97565b611850612de2565b565b61185a612e72565b61186382612f42565b6116958282612f4a565b5f611876613069565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6118a3612d97565b805f036118dc576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561193b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061195f9190613f44565b90505f81831161196f5782611971565b815b905061199061197e611d20565b5f546001600160a01b03169083612b72565b611998611d20565b6001600160a01b03167f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e51826040516119d291815260200190565b60405180910390a2505050565b6119e7612d97565b6118505f6130cb565b6001546001600160a01b03163314611a34576040517f1b8f6df300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611a40848484612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff16916001600160a01b038516917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f4091015b60405180910390a350505050565b5f611ad233612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611b88576001820180546fffffffffffffffffffffffffffffffff1690555f611b2c828533612624565b90508160075f828254611b3f9190613e21565b90915550506060810151604080518481526020810187905261ffff9092169133917f28a4391b81854dd0b9a033088421ef92664cbb2ce533b69baa569d4d1b81b3839101611aba565b505050565b3380611b97612422565b6001600160a01b031614611be7576040517f118cdaa70000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024015b60405180910390fd5b611bf0816130cb565b50565b5f611bff838333612624565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f40910160405180910390a35f54611b88906001600160a01b031633308661311b565b611c96612d97565b61185061315a565b611ca6612d97565b600180546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f111a961d91cf441fe07e7bfddc128b30ab56974d1a76851e969e0642fdb2dd5091015b60405180910390a15050565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b611d5c612d97565b600a80549082905560408051828152602081018490527f759d29a964e1aa0e3273a781eec37e160daa40a40342ad659d83028dd14aacd19101611d14565b611da2612d97565b5f80546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611e01573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e259190613f44565b905060075460085482611e389190613e21565b611e429190613e21565b821115611e7b576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e845f612c50565b506003544210611ea357600254611e9b9083613e78565b600555611ee3565b5f42600354611eb29190613e21565b90505f60055482611ec39190613e34565b600254909150611ed38286613e0e565b611edd9190613e78565b60055550505b426004819055600254611ef591613e0e565b6003819055508160075f828254611f0c9190613e0e565b90915550506040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d90602001611d14565b611f49612d97565b5f546001600160a01b0383811691161480611f6b57506001600160a01b038216155b15611fa2576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03611fdb576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611fe4611d20565b9050611ffa6001600160a01b0384168284612b72565b604080516001600160a01b038581168252602082018590528316917f4b3832ed948bc80ab35e8cab3a5923e6e1a57696d02c846a8b6f54d39bf9acf091016119d2565b5f8061204983856129bc565b90505f670de0b6b3a76400006301da9c006005546120679190613e34565b6120719190613e34565b61207c906064613e34565b90506113a2828287856009546120929190613e0e565b61100a9190613e34565b6120a78282336131d3565b604051818152829033907fe6afb5ca7cc84435baf09da39fcb42fc0fb8bdfef6c3ff2ce9fce2c70a18f8219060200160405180910390a35f54611695906001600160a01b031633308461311b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f8115801561213f5750825b90505f8267ffffffffffffffff16600114801561215b5750303b155b905081158015612169575080155b156121a0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156122015784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b5f80546001600160a01b03808b167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560018054928a16929091169190911790556309450c0060025562093a80600a556122608661340f565b612268613420565b612270613420565b612278613428565b61228061315a565b83156122e15784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6122f3612d97565b42600354111561232f576040517f449a6ba000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280549082905560408051828152602081018490527fd20a04eb2807bde8cbdf16ef27a46d94a3162d81818f1781c0fe4ed9194ca3919101611d14565b5f61237733612c50565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611b88576001820180546fffffffffffffffffffffffffffffffff1690556123d08382336131d3565b8060075f8282546123e19190613e21565b9091555050604051818152839033907fbcb84e4496de59b7cc314368190ec54380f616d6535422e388531cc05ba1b8829060200160405180910390a3505050565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00611d44565b612452612d97565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03831690811782556124ae611d20565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b5f6124f133612c50565b90505f61251d836040015163ffffffff16845f01516fffffffffffffffffffffffffffffffff166129bc565b82549091506fffffffffffffffffffffffffffffffff168111156125545781546fffffffffffffffffffffffffffffffff16612556565b805b90508060095f8282546125699190613e21565b90915550612578905081612d42565b825483905f9061259b9084906fffffffffffffffffffffffffffffffff16613f5b565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050565b5f64ffffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526028600482015260248101839052604401611bde565b5090565b6040805160a0810182525f80825260208201819052918101829052606081018290526080810191909152835f03612687576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61269183612c50565b90505f61269e85876129bc565b9050805f036126d9576040517f19a2a9bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060095f8282546126ea9190613e0e565b925050819055508560085f8282546127029190613e0e565b90915550612711905081612d42565b825483905f906127349084906fffffffffffffffffffffffffffffffff16613f14565b82546101009290920a6fffffffffffffffffffffffffffffffff81810219909316918316021790915583545f925070010000000000000000000000000000000090041683601061278383613f84565b91906101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506fffffffffffffffffffffffffffffffff1690505f86426127da9190613e0e565b90506040518060a001604052806127f08a612d42565b6fffffffffffffffffffffffffffffffff168152602001612810836125d6565b64ffffffffff16815260200161282589613438565b63ffffffff16815260200161283984613481565b61ffff90811682525f60209283018190526001600160a01b039099168952600c82526040808a20958a52948252978490208251815492840151958401516060850151608086015164ffffffffff9081167b01000000000000000000000000000000000000000000000000000000027affffffffffffffffffffffffffffffffffffffffffffffffffffff92909d16790100000000000000000000000000000000000000000000000000027fffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff909416750100000000000000000000000000000000000000000002939093167fffffffffff000000000000ffffffffffffffffffffffffffffffffffffffffff99909116700100000000000000000000000000000000027fffffffffffffffffffffff0000000000000000000000000000000000000000009096166fffffffffffffffffffffffffffffffff90941693909317949094179690961617949094171696909617909155509295945050505050565b5f825f036129e3576103e86129d28360fa613e34565b6129dc9190613e78565b9050612a75565b6301da9c0083036129fd576103e86129d2836101f4613e34565b6302c7ea008303612a17576103e86129d283610271613e34565b6303b538008303612a31576103e86129d2836102ee613e34565b63058fd4008303612a43575080612a75565b6040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612ace57838281612ac457612ac4613e4b565b04925050506115d1565b808411612b07576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6040516001600160a01b03838116602483015260448201839052611b8891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134c8565b5f6009545f03612bf7575060065490565b5f600454612c03613542565b612c0d9190613e21565b9050600954670de0b6b3a764000060055483612c299190613e34565b612c339190613e34565b612c3d9190613e78565b600654612c4a9190613e0e565b91505090565b5f612c59613558565b5f612c62612be6565b9050801580612c72575060065481115b15612c88576006819055612c84613542565b6004555b6001600160a01b0383165f818152600b60205260409020925015612d3c57612cb7612cb2846112ef565b612d42565b6001830180546fffffffffffffffffffffffffffffffff928316700100000000000000000000000000000000029216919091179055600654612cf890612d42565b6001830180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790555b50919050565b5f6fffffffffffffffffffffffffffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401611bde565b33612da0611d20565b6001600160a01b031614611850576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611bde565b612dea6135b4565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f00000000000000000000000074363f131e00a4ff91af7c32a85b3c83e29cc8c8161480612f0b57507f00000000000000000000000074363f131e00a4ff91af7c32a85b3c83e29cc8c86001600160a01b0316612eff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611850576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bf0612d97565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612fc2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612fbf91810190613f44565b60015b613003576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611bde565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc811461305f576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611bde565b611b88838361360f565b306001600160a01b037f00000000000000000000000074363f131e00a4ff91af7c32a85b3c83e29cc8c81614611850576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815561169582613664565b6040516001600160a01b0384811660248301528381166044830152606482018390526131549186918216906323b872dd90608401612b9f565b50505050565b613162613558565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833612e54565b6001600160a01b0381165f908152600c602090815260408083208684529091528120805490916fffffffffffffffffffffffffffffffff9091169003613245576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff161561329c576040517ee24fbd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff16156132fb576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6133065f856129bc565b90505f61331284612c50565b90508160095f8282546133259190613e0e565b925050819055508460085f82825461333d9190613e0e565b9091555061334c905082612d42565b815482905f9061336f9084906fffffffffffffffffffffffffffffffff16613f14565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506133ae85612d42565b835484905f906133d19084906fffffffffffffffffffffffffffffffff16613f14565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050505050565b6134176136ec565b611bf081613753565b6118506136ec565b6134306136ec565b61185061379d565b5f63ffffffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526020600482015260248101839052604401611bde565b5f61ffff821115612620576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526010600482015260248101839052604401611bde565b5f6134dc6001600160a01b038416836137ee565b905080515f141580156135005750808060200190518101906134fe9190613fb2565b155b15611b88576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611bde565b5f6003544210613553575060035490565b504290565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611850576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611850576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613618826137fb565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561365c57611b8882826138a2565b61169561390b565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611850576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61375b6136ec565b6001600160a01b038116611be7576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f6004820152602401611bde565b6137a56136ec565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60606115d183835f613943565b806001600160a01b03163b5f03613849576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611bde565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516138be9190613fd1565b5f60405180830381855af49150503d805f81146138f6576040519150601f19603f3d011682016040523d82523d5f602084013e6138fb565b606091505b50915091506113a28583836139e7565b3415611850576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015613981576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611bde565b5f80856001600160a01b0316848660405161399c9190613fd1565b5f6040518083038185875af1925050503d805f81146139d6576040519150601f19603f3d011682016040523d82523d5f602084013e6139db565b606091505b509150915061100f8683835b6060826139fc576139f782613a5c565b6115d1565b8151158015613a1357506001600160a01b0384163b155b15613a55576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611bde565b50806115d1565b805115613a6c5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60208284031215613aae575f80fd5b5035919050565b5f8060408385031215613ac6575f80fd5b50508035926020909101359150565b6001600160a01b0381168114611bf0575f80fd5b5f8060408385031215613afa575f80fd5b8235613b0581613ad5565b946020939093013593505050565b5f60208284031215613b23575f80fd5b81356115d181613ad5565b5f805f60608486031215613b40575f80fd5b8335613b4b81613ad5565b95602085013595506040909401359392505050565b602080825282518282018190525f919060409081850190868401855b82811015613be657815180516fffffffffffffffffffffffffffffffff1685528681015164ffffffffff908116888701528682015163ffffffff168787015260608083015161ffff1690870152608091820151169085015260a09093019290850190600101613b7c565b5091979650505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f8060408385031215613c31575f80fd5b8235613c3c81613ad5565b9150602083013567ffffffffffffffff80821115613c58575f80fd5b818501915085601f830112613c6b575f80fd5b813581811115613c7d57613c7d613bf3565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613cc357613cc3613bf3565b81604052828152886020848701011115613cdb575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f805f60608486031215613d0e575f80fd5b83359250602084013591506040840135613d2781613ad5565b809150509250925092565b5f5b83811015613d4c578181015183820152602001613d34565b50505f910152565b602081525f8251806020840152613d72816040850160208701613d32565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b5f805f60608486031215613db6575f80fd5b8335613dc181613ad5565b92506020840135613dd181613ad5565b91506040840135613d2781613ad5565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b80820180821115612a7557612a75613de1565b81810381811115612a7557612a75613de1565b8082028115828204841417612a7557612a75613de1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82613eab577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f0d57613f0d613de1565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115613f3d57613f3d613de1565b5092915050565b5f60208284031215613f54575f80fd5b5051919050565b6fffffffffffffffffffffffffffffffff828116828216039080821115613f3d57613f3d613de1565b5f6fffffffffffffffffffffffffffffffff808316818103613fa857613fa8613de1565b6001019392505050565b5f60208284031215613fc2575f80fd5b815180151581146115d1575f80fd5b5f8251613fe2818460208701613d32565b919091019291505056fea2646970667358221220508c51a3578a5963e55424d006f02b4318886b7763c9dc932b1f4b42402ee01564736f6c63430008170033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.