Overview
ETH Balance
ETH Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Exit | 135161463 | 282 days ago | IN | 0 ETH | 0.000000495465 |
View more zero value Internal Transactions in Advanced View mode
Cross-Chain Transactions
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x9C5AeA29...B93D60681 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {PausableUpgradeable} from
"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {Ownable2StepUpgradeable} from
"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {IKwenta} from "./interfaces/IKwenta.sol";
import {IStakingRewardsV2} from "./interfaces/IStakingRewardsV2.sol";
import {IStakingRewardsNotifier} from "./interfaces/IStakingRewardsNotifier.sol";
import {IRewardEscrowV2} from "./interfaces/IRewardEscrowV2.sol";
/// @title KWENTA Staking Rewards V2
/// @author Originally inspired by SYNTHETIX StakingRewards
/// @author Kwenta's StakingRewards V1 by JaredBorders ([email protected]), JChiaramonte7 ([email protected])
/// @author StakingRewardsV2 (this) by tommyrharper ([email protected])
/// @notice Updated version of Synthetix's StakingRewards with new features specific to Kwenta
contract StakingRewardsV2 is
IStakingRewardsV2,
Ownable2StepUpgradeable,
PausableUpgradeable,
UUPSUpgradeable
{
/*///////////////////////////////////////////////////////////////
CONSTANTS/IMMUTABLES
///////////////////////////////////////////////////////////////*/
/// @notice minimum time length of the unstaking cooldown period
uint256 public constant MIN_COOLDOWN_PERIOD = 1 weeks;
/// @notice maximum time length of the unstaking cooldown period
uint256 public constant MAX_COOLDOWN_PERIOD = 52 weeks;
/// @notice Contract for KWENTA ERC20 token - used for BOTH staking and rewards
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IKwenta public immutable kwenta;
/// @notice escrow contract which holds (and may stake) reward tokens
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IRewardEscrowV2 public immutable rewardEscrow;
/// @notice handles reward token minting logic
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IStakingRewardsNotifier public immutable rewardsNotifier;
/// @notice Contract for USDC ERC20 token - used for rewards
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IERC20 public immutable usdc;
/// @notice Used to scale USDC precision to 18 decimals
uint256 private constant PRECISION = 1e12;
/*///////////////////////////////////////////////////////////////
STATE
///////////////////////////////////////////////////////////////*/
/// @notice list of checkpoints with the number of tokens staked by address
/// @dev this includes staked escrowed tokens
mapping(address => Checkpoint[]) public balancesCheckpoints;
/// @notice list of checkpoints with the number of staked escrow tokens by address
mapping(address => Checkpoint[]) public escrowedBalancesCheckpoints;
/// @notice list of checkpoints with the total number of tokens staked in this contract
Checkpoint[] public totalSupplyCheckpoints;
/// @notice marks applicable reward period finish time
uint256 public periodFinish;
/// @notice amount of tokens minted per second
uint256 public rewardRate;
/// @notice period for rewards
uint256 public rewardsDuration;
/// @notice track last time the rewards were updated
uint256 public lastUpdateTime;
/// @notice summation of rewardRate divided by total staked tokens
uint256 public rewardPerTokenStored;
/// @inheritdoc IStakingRewardsV2
uint256 public cooldownPeriod;
/// @notice represents the rewardPerToken
/// value the last time the staker calculated earned() rewards
mapping(address => uint256) public userRewardPerTokenPaid;
/// @notice track rewards for a given user which changes when
/// a user stakes, unstakes, or claims rewards
mapping(address => uint256) public rewards;
/// @notice tracks the last time staked for a given user
mapping(address => uint256) public userLastStakeTime;
/// @notice tracks all addresses approved to take actions on behalf of a given account
mapping(address => mapping(address => bool)) public operatorApprovals;
/// @notice amount of tokens minted per second
uint256 public rewardRateUSDC;
/// @notice summation of rewardRate divided by total staked tokens
uint256 public rewardPerTokenStoredUSDC;
/// @notice represents the rewardPerToken for USDC rewards
/// value the last time the staker calculated earned() rewards
mapping(address => uint256) public userRewardPerTokenPaidUSDC;
/// @notice track USDC rewards for a given user which changes when
/// a user stakes, unstakes, or claims rewards
mapping(address => uint256) public rewardsUSDC;
/*///////////////////////////////////////////////////////////////
AUTH
///////////////////////////////////////////////////////////////*/
/// @notice access control modifier for rewardEscrow
modifier onlyRewardEscrow() {
_onlyRewardEscrow();
_;
}
function _onlyRewardEscrow() internal view {
if (msg.sender != address(rewardEscrow)) revert OnlyRewardEscrow();
}
/// @notice access control modifier for rewardsNotifier
modifier onlyRewardsNotifier() {
_onlyRewardsNotifier();
_;
}
function _onlyRewardsNotifier() internal view {
if (msg.sender != address(rewardsNotifier)) revert OnlyRewardsNotifier();
}
/// @notice only allow execution after the unstaking cooldown period has elapsed
modifier afterCooldown(address _account) {
_afterCooldown(_account);
_;
}
function _afterCooldown(address _account) internal view {
uint256 canUnstakeAt = userLastStakeTime[_account] + cooldownPeriod;
if (canUnstakeAt > block.timestamp) revert MustWaitForUnlock(canUnstakeAt);
}
/*///////////////////////////////////////////////////////////////
CONSTRUCTOR / INITIALIZER
///////////////////////////////////////////////////////////////*/
/// @dev disable default constructor to disable the implementation contract
/// Actual contract construction will take place in the initialize function via proxy
/// @custom:oz-upgrades-unsafe-allow constructor
/// @param _kwenta The address for the KWENTA ERC20 token
/// @param _usdc The address for the USDC ERC20 token
/// @param _rewardEscrow The address for the RewardEscrowV2 contract
/// @param _rewardsNotifier The address for the StakingRewardsNotifier contract
constructor(address _kwenta, address _usdc, address _rewardEscrow, address _rewardsNotifier) {
if (
_kwenta == address(0) || _usdc == address(0) || _rewardEscrow == address(0)
|| _rewardsNotifier == address(0)
) {
revert ZeroAddress();
}
_disableInitializers();
// define reward/staking token
kwenta = IKwenta(_kwenta);
usdc = IERC20(_usdc);
// define contracts which will interact with StakingRewards
rewardEscrow = IRewardEscrowV2(_rewardEscrow);
rewardsNotifier = IStakingRewardsNotifier(_rewardsNotifier);
}
/// @inheritdoc IStakingRewardsV2
function initialize(address _contractOwner) external initializer {
if (_contractOwner == address(0)) revert ZeroAddress();
// initialize owner
__Ownable2Step_init();
__Pausable_init();
__UUPSUpgradeable_init();
// transfer ownership
_transferOwnership(_contractOwner);
// define values
rewardsDuration = 1 weeks;
cooldownPeriod = 2 weeks;
}
/*///////////////////////////////////////////////////////////////
VIEWS
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function totalSupply() public view returns (uint256) {
uint256 length = totalSupplyCheckpoints.length;
unchecked {
return length == 0 ? 0 : totalSupplyCheckpoints[length - 1].value;
}
}
/// @inheritdoc IStakingRewardsV2
function balanceOf(address _account) public view returns (uint256) {
Checkpoint[] storage checkpoints = balancesCheckpoints[_account];
uint256 length = checkpoints.length;
unchecked {
return length == 0 ? 0 : checkpoints[length - 1].value;
}
}
/// @inheritdoc IStakingRewardsV2
function escrowedBalanceOf(address _account) public view returns (uint256) {
Checkpoint[] storage checkpoints = escrowedBalancesCheckpoints[_account];
uint256 length = checkpoints.length;
unchecked {
return length == 0 ? 0 : checkpoints[length - 1].value;
}
}
/// @inheritdoc IStakingRewardsV2
function nonEscrowedBalanceOf(address _account) public view returns (uint256) {
return balanceOf(_account) - escrowedBalanceOf(_account);
}
/// @inheritdoc IStakingRewardsV2
function unstakedEscrowedBalanceOf(address _account) public view returns (uint256) {
return rewardEscrow.escrowedBalanceOf(_account) - escrowedBalanceOf(_account);
}
/*///////////////////////////////////////////////////////////////
STAKE/UNSTAKE
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function stake(uint256 _amount) external whenNotPaused updateReward(msg.sender) {
if (_amount == 0) revert AmountZero();
// update state
userLastStakeTime[msg.sender] = block.timestamp;
_addTotalSupplyCheckpoint(totalSupply() + _amount);
_addBalancesCheckpoint(msg.sender, balanceOf(msg.sender) + _amount);
// emit staking event and index msg.sender
emit Staked(msg.sender, _amount);
// transfer token to this contract from the caller
kwenta.transferFrom(msg.sender, address(this), _amount);
}
/// @inheritdoc IStakingRewardsV2
function unstake(uint256 _amount)
public
whenNotPaused
updateReward(msg.sender)
afterCooldown(msg.sender)
{
if (_amount == 0) revert AmountZero();
uint256 nonEscrowedBalance = nonEscrowedBalanceOf(msg.sender);
if (_amount > nonEscrowedBalance) revert InsufficientBalance(nonEscrowedBalance);
// update state
_addTotalSupplyCheckpoint(totalSupply() - _amount);
_addBalancesCheckpoint(msg.sender, balanceOf(msg.sender) - _amount);
// emit unstake event and index msg.sender
emit Unstaked(msg.sender, _amount);
// transfer token from this contract to the caller
kwenta.transfer(msg.sender, _amount);
}
/// @inheritdoc IStakingRewardsV2
function stakeEscrow(uint256 _amount) external {
_stakeEscrow(msg.sender, _amount);
}
function _stakeEscrow(address _account, uint256 _amount)
internal
whenNotPaused
updateReward(_account)
{
if (_amount == 0) revert AmountZero();
uint256 unstakedEscrow = unstakedEscrowedBalanceOf(_account);
if (_amount > unstakedEscrow) revert InsufficientUnstakedEscrow(unstakedEscrow);
// update state
userLastStakeTime[_account] = block.timestamp;
_addBalancesCheckpoint(_account, balanceOf(_account) + _amount);
_addEscrowedBalancesCheckpoint(_account, escrowedBalanceOf(_account) + _amount);
// updates total supply despite no new staking token being transfered.
// escrowed tokens are locked in RewardEscrow
_addTotalSupplyCheckpoint(totalSupply() + _amount);
// emit escrow staking event and index account
emit EscrowStaked(_account, _amount);
}
/// @inheritdoc IStakingRewardsV2
function unstakeEscrow(uint256 _amount) external afterCooldown(msg.sender) {
_unstakeEscrow(msg.sender, _amount);
}
/// @inheritdoc IStakingRewardsV2
function unstakeEscrowSkipCooldown(address _account, uint256 _amount)
external
onlyRewardEscrow
{
_unstakeEscrow(_account, _amount);
}
function _unstakeEscrow(address _account, uint256 _amount)
internal
whenNotPaused
updateReward(_account)
{
if (_amount == 0) revert AmountZero();
uint256 escrowedBalance = escrowedBalanceOf(_account);
if (_amount > escrowedBalance) revert InsufficientBalance(escrowedBalance);
// update state
_addBalancesCheckpoint(_account, balanceOf(_account) - _amount);
_addEscrowedBalancesCheckpoint(_account, escrowedBalanceOf(_account) - _amount);
// updates total supply despite no new staking token being transfered.
// escrowed tokens are locked in RewardEscrow
_addTotalSupplyCheckpoint(totalSupply() - _amount);
// emit escrow unstaked event and index account
emit EscrowUnstaked(_account, _amount);
}
/// @inheritdoc IStakingRewardsV2
function exit() external {
unstake(nonEscrowedBalanceOf(msg.sender));
_getReward(msg.sender);
}
/*///////////////////////////////////////////////////////////////
CLAIM REWARDS
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function getReward() external {
_getReward(msg.sender);
}
function _getReward(address _account) internal {
_getReward(_account, _account);
}
function _getReward(address _account, address _to)
internal
whenNotPaused
updateReward(_account)
{
uint256 reward = rewards[_account];
if (reward > 0) {
// update state (first)
rewards[_account] = 0;
// emit reward claimed event and index account
emit RewardPaid(_account, reward);
// transfer token from this contract to the rewardEscrow
// and create a vesting entry at the _to address
kwenta.transfer(address(rewardEscrow), reward);
rewardEscrow.appendVestingEntry(_to, reward);
}
uint256 rewardUSDC = rewardsUSDC[_account] / PRECISION;
if (rewardUSDC > 0) {
// update state (first)
rewardsUSDC[_account] = 0;
// emit reward claimed event and index account
emit RewardPaidUSDC(_account, rewardUSDC);
// transfer token from this contract to the account
// as newly issued rewards from inflation are now issued as non-escrowed
usdc.transfer(_to, rewardUSDC);
}
}
/// @inheritdoc IStakingRewardsV2
function compound() external {
_compound(msg.sender);
}
/// @dev internal helper to compound for a given account
/// @param _account the account to compound for
function _compound(address _account) internal {
_getReward(_account);
_stakeEscrow(_account, unstakedEscrowedBalanceOf(_account));
}
/*///////////////////////////////////////////////////////////////
REWARD UPDATE CALCULATIONS
///////////////////////////////////////////////////////////////*/
/// @notice update reward state for the account and contract
/// @param _account: address of account which rewards are being updated for
/// @dev contract state not specific to an account will be updated also
modifier updateReward(address _account) {
_updateReward(_account);
_;
}
function _updateReward(address _account) internal {
rewardPerTokenStored = rewardPerToken();
rewardPerTokenStoredUSDC = rewardPerTokenUSDC();
lastUpdateTime = lastTimeRewardApplicable();
if (_account != address(0)) {
// update amount of rewards a user can claim
rewards[_account] = earned(_account);
// update reward per token staked AT this given time
// (i.e. when this user is interacting with StakingRewards)
userRewardPerTokenPaid[_account] = rewardPerTokenStored;
rewardsUSDC[_account] = earnedUSDC(_account);
userRewardPerTokenPaidUSDC[_account] = rewardPerTokenStoredUSDC;
}
}
/// @inheritdoc IStakingRewardsV2
function getRewardForDuration() external view returns (uint256) {
return rewardRate * rewardsDuration;
}
function getRewardForDurationUSDC() external view returns (uint256) {
return rewardRateUSDC * rewardsDuration;
}
/// @inheritdoc IStakingRewardsV2
function rewardPerToken() public view returns (uint256) {
uint256 allTokensStaked = totalSupply();
if (allTokensStaked == 0) {
return rewardPerTokenStored;
}
return rewardPerTokenStored
+ (((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18) / allTokensStaked);
}
/// @inheritdoc IStakingRewardsV2
function rewardPerTokenUSDC() public view returns (uint256) {
uint256 allTokensStaked = totalSupply();
if (allTokensStaked == 0) {
return rewardPerTokenStoredUSDC;
}
return rewardPerTokenStoredUSDC
+ (
((lastTimeRewardApplicable() - lastUpdateTime) * rewardRateUSDC * 1e18)
/ allTokensStaked
);
}
/// @inheritdoc IStakingRewardsV2
function lastTimeRewardApplicable() public view returns (uint256) {
return block.timestamp < periodFinish ? block.timestamp : periodFinish;
}
/// @inheritdoc IStakingRewardsV2
function earned(address _account) public view returns (uint256) {
uint256 totalBalance = balanceOf(_account);
return ((totalBalance * (rewardPerToken() - userRewardPerTokenPaid[_account])) / 1e18)
+ rewards[_account];
}
/// @inheritdoc IStakingRewardsV2
function earnedUSDC(address _account) public view returns (uint256) {
uint256 totalBalance = balanceOf(_account);
return (
(totalBalance * (rewardPerTokenUSDC() - userRewardPerTokenPaidUSDC[_account])) / 1e18
) + rewardsUSDC[_account];
}
/*///////////////////////////////////////////////////////////////
DELEGATION
///////////////////////////////////////////////////////////////*/
/// @notice access control modifier for approved operators
modifier onlyOperator(address _accountOwner) {
_onlyOperator(_accountOwner);
_;
}
function _onlyOperator(address _accountOwner) internal view {
if (!operatorApprovals[_accountOwner][msg.sender]) revert NotApproved();
}
/// @inheritdoc IStakingRewardsV2
function approveOperator(address _operator, bool _approved) external {
if (_operator == msg.sender) revert CannotApproveSelf();
operatorApprovals[msg.sender][_operator] = _approved;
emit OperatorApproved(msg.sender, _operator, _approved);
}
/// @inheritdoc IStakingRewardsV2
function stakeEscrowOnBehalf(address _account, uint256 _amount)
external
onlyOperator(_account)
{
_stakeEscrow(_account, _amount);
}
/// @inheritdoc IStakingRewardsV2
function getRewardOnBehalf(address _account) external onlyOperator(_account) {
_getReward(_account);
}
/// @inheritdoc IStakingRewardsV2
function compoundOnBehalf(address _account) external onlyOperator(_account) {
_compound(_account);
}
/*///////////////////////////////////////////////////////////////
CHECKPOINTING VIEWS
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function balancesCheckpointsLength(address _account) external view returns (uint256) {
return balancesCheckpoints[_account].length;
}
/// @inheritdoc IStakingRewardsV2
function escrowedBalancesCheckpointsLength(address _account) external view returns (uint256) {
return escrowedBalancesCheckpoints[_account].length;
}
/// @inheritdoc IStakingRewardsV2
function totalSupplyCheckpointsLength() external view returns (uint256) {
return totalSupplyCheckpoints.length;
}
/// @inheritdoc IStakingRewardsV2
function balanceAtTime(address _account, uint256 _timestamp) external view returns (uint256) {
return _checkpointBinarySearch(balancesCheckpoints[_account], _timestamp);
}
/// @inheritdoc IStakingRewardsV2
function escrowedBalanceAtTime(address _account, uint256 _timestamp)
external
view
returns (uint256)
{
return _checkpointBinarySearch(escrowedBalancesCheckpoints[_account], _timestamp);
}
/// @inheritdoc IStakingRewardsV2
function totalSupplyAtTime(uint256 _timestamp) external view returns (uint256) {
return _checkpointBinarySearch(totalSupplyCheckpoints, _timestamp);
}
/// @notice finds the value of the checkpoint at a given timestamp
/// @param _checkpoints: array of checkpoints to search
/// @param _timestamp: timestamp to check
/// @dev returns 0 if no checkpoints exist, uses iterative binary search
/// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent
/// values as further transactions changing the balances can still occur within the same block.
function _checkpointBinarySearch(Checkpoint[] storage _checkpoints, uint256 _timestamp)
internal
view
returns (uint256)
{
uint256 length = _checkpoints.length;
if (length == 0) return 0;
uint256 min = 0;
uint256 max = length - 1;
if (_checkpoints[min].ts > _timestamp) return 0;
if (_checkpoints[max].ts <= _timestamp) return _checkpoints[max].value;
while (max > min) {
uint256 midpoint = (max + min + 1) / 2;
if (_checkpoints[midpoint].ts <= _timestamp) min = midpoint;
else max = midpoint - 1;
}
assert(min == max);
return _checkpoints[min].value;
}
/*///////////////////////////////////////////////////////////////
UPDATE CHECKPOINTS
///////////////////////////////////////////////////////////////*/
/// @notice add a new balance checkpoint for an account
/// @param _account: address of account to add checkpoint for
/// @param _value: value of checkpoint to add
function _addBalancesCheckpoint(address _account, uint256 _value) internal {
_addCheckpoint(balancesCheckpoints[_account], _value);
}
/// @notice add a new escrowed balance checkpoint for an account
/// @param _account: address of account to add checkpoint for
/// @param _value: value of checkpoint to add
function _addEscrowedBalancesCheckpoint(address _account, uint256 _value) internal {
_addCheckpoint(escrowedBalancesCheckpoints[_account], _value);
}
/// @notice add a new total supply checkpoint
/// @param _value: value of checkpoint to add
function _addTotalSupplyCheckpoint(uint256 _value) internal {
_addCheckpoint(totalSupplyCheckpoints, _value);
}
/// @notice Adds a new checkpoint or updates the last one
/// @param checkpoints The array of checkpoints to modify
/// @param _value The new value to add as a checkpoint
/// @dev If the last checkpoint is from a different block, a new checkpoint is added.
/// If it's from the current block, the value of the last checkpoint is updated.
function _addCheckpoint(Checkpoint[] storage checkpoints, uint256 _value) internal {
uint256 length = checkpoints.length;
uint256 lastTimestamp;
unchecked {
lastTimestamp = length == 0 ? 0 : checkpoints[length - 1].ts;
}
if (lastTimestamp != block.timestamp) {
checkpoints.push(
Checkpoint({
ts: uint64(block.timestamp),
blk: uint64(block.number),
value: uint128(_value)
})
);
} else {
unchecked {
checkpoints[length - 1].value = uint128(_value);
}
}
}
/*///////////////////////////////////////////////////////////////
SETTINGS
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function notifyRewardAmount(uint256 _reward, uint256 _rewardUsdc)
external
onlyRewardsNotifier
updateReward(address(0))
{
if (block.timestamp >= periodFinish) {
rewardRate = _reward / rewardsDuration;
rewardRateUSDC = (_rewardUsdc * PRECISION) / rewardsDuration;
} else {
uint256 remaining = periodFinish - block.timestamp;
uint256 leftover = remaining * rewardRate;
rewardRate = (_reward + leftover) / rewardsDuration;
uint256 leftoverUsdc = remaining * rewardRateUSDC;
rewardRateUSDC = (_rewardUsdc * PRECISION + leftoverUsdc) / rewardsDuration;
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp + rewardsDuration;
emit RewardAdded(_reward, _rewardUsdc);
}
/// @inheritdoc IStakingRewardsV2
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
if (block.timestamp <= periodFinish) revert RewardsPeriodNotComplete();
if (_rewardsDuration == 0) revert RewardsDurationCannotBeZero();
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(rewardsDuration);
}
/// @inheritdoc IStakingRewardsV2
function setCooldownPeriod(uint256 _cooldownPeriod) external onlyOwner {
if (_cooldownPeriod < MIN_COOLDOWN_PERIOD) revert CooldownPeriodTooLow(MIN_COOLDOWN_PERIOD);
if (_cooldownPeriod > MAX_COOLDOWN_PERIOD) {
revert CooldownPeriodTooHigh(MAX_COOLDOWN_PERIOD);
}
cooldownPeriod = _cooldownPeriod;
emit CooldownPeriodUpdated(cooldownPeriod);
}
/*///////////////////////////////////////////////////////////////
PAUSABLE
///////////////////////////////////////////////////////////////*/
/// @inheritdoc IStakingRewardsV2
function pauseStakingRewards() external onlyOwner {
_pause();
}
/// @inheritdoc IStakingRewardsV2
function unpauseStakingRewards() external onlyOwner {
_unpause();
}
/*///////////////////////////////////////////////////////////////
MISCELLANEOUS
///////////////////////////////////////////////////////////////*/
/// @dev this function is used by the proxy to set the access control for upgrading the implementation contract
function _authorizeUpgrade(address _newImplementation) internal override onlyOwner {}
/// @inheritdoc IStakingRewardsV2
function recoverERC20(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
if (_tokenAddress == address(kwenta)) revert CannotRecoverStakingToken();
if (_tokenAddress == address(usdc)) revert CannotRecoverRewardToken();
emit Recovered(_tokenAddress, _tokenAmount);
IERC20(_tokenAddress).transfer(owner(), _tokenAmount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../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 {
/**
* @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);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_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) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./OwnableUpgradeable.sol";
import "../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.
*
* By default, the owner account will be the one that deploys the contract. 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 {
function __Ownable2Step_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
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 {
_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 {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() external {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./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.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @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() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @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() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @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 override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
interface IKwenta is IERC20 {
function mint(address account, uint amount) external;
function burn(uint amount) external;
function setSupplySchedule(address _supplySchedule) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IStakingRewardsV2 {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice A checkpoint for tracking values at a given timestamp
struct Checkpoint {
// The timestamp when the value was generated
uint64 ts;
// The block number when the value was generated
uint64 blk;
// The value of the checkpoint
/// @dev will not overflow unless it value reaches 340 quintillion
/// This number should be impossible to reach with the total supply of $KWENTA
uint128 value;
}
/*///////////////////////////////////////////////////////////////
INITIALIZER
///////////////////////////////////////////////////////////////*/
/// @notice Initializes the contract
/// @param _owner: owner of this contract
/// @dev this function should be called via proxy, not via direct contract interaction
function initialize(address _owner) external;
/*//////////////////////////////////////////////////////////////
Views
//////////////////////////////////////////////////////////////*/
// token state
/// @dev returns staked tokens which will likely not be equal to total tokens
/// in the contract since reward and staking tokens are the same
/// @return total amount of tokens that are being staked
function totalSupply() external view returns (uint256);
// staking state
/// @notice Returns the total number of staked tokens for a user
/// the sum of all escrowed and non-escrowed tokens
/// @param _account: address of potential staker
/// @return amount of tokens staked by account
function balanceOf(address _account) external view returns (uint256);
/// @notice Getter function for number of staked escrow tokens
/// @param _account address to check the escrowed tokens staked
/// @return amount of escrowed tokens staked
function escrowedBalanceOf(address _account) external view returns (uint256);
/// @notice Getter function for number of staked non-escrow tokens
/// @param _account address to check the non-escrowed tokens staked
/// @return amount of non-escrowed tokens staked
function nonEscrowedBalanceOf(address _account) external view returns (uint256);
/// @notice Getter function for the total number of escrowed tokens that are not not staked
/// @param _account: address to check
/// @return amount of tokens escrowed but not staked
function unstakedEscrowedBalanceOf(address _account) external view returns (uint256);
/// @notice the period of time a user has to wait after staking to unstake
function cooldownPeriod() external view returns (uint256);
// rewards
/// @notice calculate the total rewards for one duration based on the current rate
/// @return rewards for the duration specified by rewardsDuration
function getRewardForDuration() external view returns (uint256);
/// @notice calculate running sum of reward per total tokens staked
/// at this specific time
/// @return running sum of reward per total tokens staked
function rewardPerToken() external view returns (uint256);
/// @notice calculate running sum of USDC reward per total tokens staked
/// at this specific time
/// @return running sum of USDC reward per total tokens staked
function rewardPerTokenUSDC() external view returns (uint256);
/// @notice get the last time a reward is applicable for a given user
/// @return timestamp of the last time rewards are applicable
function lastTimeRewardApplicable() external view returns (uint256);
/// @notice determine how much reward token an account has earned thus far
/// @param _account: address of account earned amount is being calculated for
function earned(address _account) external view returns (uint256);
/// @notice determine how much USDC reward an account has earned thus far
/// @param _account: address of account earned amount is being calculated for
function earnedUSDC(address _account) external view returns (uint256);
// checkpointing
/// @notice get the number of balances checkpoints for an account
/// @param _account: address of account to check
/// @return number of balances checkpoints
function balancesCheckpointsLength(address _account) external view returns (uint256);
/// @notice get the number of escrowed balance checkpoints for an account
/// @param _account: address of account to check
/// @return number of escrowed balance checkpoints
function escrowedBalancesCheckpointsLength(address _account) external view returns (uint256);
/// @notice get the number of total supply checkpoints
/// @return number of total supply checkpoints
function totalSupplyCheckpointsLength() external view returns (uint256);
/// @notice get a users balance at a given timestamp
/// @param _account: address of account to check
/// @param _timestamp: timestamp to check
/// @return balance at given timestamp
/// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent
/// values as further transactions changing the balances can still occur within the same block.
function balanceAtTime(address _account, uint256 _timestamp) external view returns (uint256);
/// @notice get a users escrowed balance at a given timestamp
/// @param _account: address of account to check
/// @param _timestamp: timestamp to check
/// @return escrowed balance at given timestamp
/// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent
/// values as further transactions changing the balances can still occur within the same block.
function escrowedBalanceAtTime(address _account, uint256 _timestamp)
external
view
returns (uint256);
/// @notice get the total supply at a given timestamp
/// @param _timestamp: timestamp to check
/// @return total supply at given timestamp
/// @dev if called with a timestamp that equals the current block timestamp, then the function might return inconsistent
/// values as further transactions changing the balances can still occur within the same block.
function totalSupplyAtTime(uint256 _timestamp) external view returns (uint256);
/*//////////////////////////////////////////////////////////////
Mutative
//////////////////////////////////////////////////////////////*/
// Staking/Unstaking
/// @notice stake token
/// @param _amount: amount to stake
/// @dev updateReward() called prior to function logic
function stake(uint256 _amount) external;
/// @notice unstake token
/// @param _amount: amount to unstake
/// @dev updateReward() called prior to function logic
function unstake(uint256 _amount) external;
/// @notice stake escrowed token
/// @param _amount: amount to stake
/// @dev updateReward() called prior to function logic
function stakeEscrow(uint256 _amount) external;
/// @notice unstake escrowed token
/// @param _amount: amount to unstake
/// @dev updateReward() called prior to function logic
function unstakeEscrow(uint256 _amount) external;
/// @notice unstake escrowed token skipping the cooldown wait period
/// @param _account: address of account to unstake from
/// @param _amount: amount to unstake
/// @dev this function is used to allow tokens to be vested at any time by RewardEscrowV2
function unstakeEscrowSkipCooldown(address _account, uint256 _amount) external;
/// @notice unstake all available staked non-escrowed tokens and
/// claim any rewards
function exit() external;
// claim rewards
/// @notice caller claims any rewards generated from staking
/// @dev rewards are escrowed in RewardEscrow
/// @dev updateReward() called prior to function logic
function getReward() external;
/// @notice claim rewards for an account and stake them
function compound() external;
// delegation
/// @notice approve an operator to collect rewards and stake escrow on behalf of the sender
/// @param operator: address of operator to approve
/// @param approved: whether or not to approve the operator
function approveOperator(address operator, bool approved) external;
/// @notice stake escrowed token on behalf of another account
/// @param _account: address of account to stake on behalf of
/// @param _amount: amount to stake
function stakeEscrowOnBehalf(address _account, uint256 _amount) external;
/// @notice caller claims any rewards generated from staking on behalf of another account
/// The rewards will be escrowed in RewardEscrow with the account as the beneficiary
/// @param _account: address of account to claim rewards for
function getRewardOnBehalf(address _account) external;
/// @notice claim and stake rewards on behalf of another account
/// @param _account: address of account to claim and stake rewards for
function compoundOnBehalf(address _account) external;
// settings
/// @notice configure reward rate
/// @param _reward: amount of token to be distributed over a period
/// @param _reward: amount of usdc to be distributed over a period
/// @dev updateReward() called prior to function logic (with zero address)
function notifyRewardAmount(uint256 _reward, uint256 _rewardUsdc) external;
/// @notice set rewards duration
/// @param _rewardsDuration: denoted in seconds
function setRewardsDuration(uint256 _rewardsDuration) external;
/// @notice set unstaking cooldown period
/// @param _cooldownPeriod: denoted in seconds
function setCooldownPeriod(uint256 _cooldownPeriod) external;
// pausable
/// @dev Triggers stopped state
function pauseStakingRewards() external;
/// @dev Returns to normal state.
function unpauseStakingRewards() external;
// misc.
/// @notice added to support recovering LP Rewards from other systems
/// such as BAL to be distributed to holders
/// @param tokenAddress: address of token to be recovered
/// @param tokenAmount: amount of token to be recovered
function recoverERC20(address tokenAddress, uint256 tokenAmount) external;
/*///////////////////////////////////////////////////////////////
EVENTS
///////////////////////////////////////////////////////////////*/
/// @notice update reward rate
/// @param reward: kwenta amount to be distributed over applicable rewards duration
/// @param rewardUsdc: usdc amount to be distributed over applicable rewards duration
event RewardAdded(uint256 reward, uint256 rewardUsdc);
/// @notice emitted when user stakes tokens
/// @param user: staker address
/// @param amount: amount staked
event Staked(address indexed user, uint256 amount);
/// @notice emitted when user unstakes tokens
/// @param user: address of user unstaking
/// @param amount: amount unstaked
event Unstaked(address indexed user, uint256 amount);
/// @notice emitted when escrow staked
/// @param user: owner of escrowed tokens address
/// @param amount: amount staked
event EscrowStaked(address indexed user, uint256 amount);
/// @notice emitted when staked escrow tokens are unstaked
/// @param user: owner of escrowed tokens address
/// @param amount: amount unstaked
event EscrowUnstaked(address user, uint256 amount);
/// @notice emitted when user claims rewards
/// @param user: address of user claiming rewards
/// @param reward: amount of reward token claimed
event RewardPaid(address indexed user, uint256 reward);
/// @notice emitted when user claims USDC rewards
/// @param user: address of user claiming rewards
/// @param reward: amount of USDC token claimed
event RewardPaidUSDC(address indexed user, uint256 reward);
/// @notice emitted when rewards duration changes
/// @param newDuration: denoted in seconds
event RewardsDurationUpdated(uint256 newDuration);
/// @notice emitted when tokens are recovered from this contract
/// @param token: address of token recovered
/// @param amount: amount of token recovered
event Recovered(address token, uint256 amount);
/// @notice emitted when the unstaking cooldown period is updated
/// @param cooldownPeriod: the new unstaking cooldown period
event CooldownPeriodUpdated(uint256 cooldownPeriod);
/// @notice emitted when an operator is approved
/// @param owner: owner of tokens
/// @param operator: address of operator
/// @param approved: whether or not operator is approved
event OperatorApproved(address owner, address operator, bool approved);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice error someone other than reward escrow calls an onlyRewardEscrow function
error OnlyRewardEscrow();
/// @notice error someone other than the rewards notifier calls an onlyRewardsNotifier function
error OnlyRewardsNotifier();
/// @notice cannot set this value to the zero address
error ZeroAddress();
/// @notice error when user tries to stake/unstake 0 tokens
error AmountZero();
/// @notice the user does not have enough tokens to unstake that amount
/// @param availableBalance: amount of tokens available to withdraw
error InsufficientBalance(uint256 availableBalance);
/// @notice error when trying to stakeEscrow more than the unstakedEscrow available
/// @param unstakedEscrow amount of unstaked escrow
error InsufficientUnstakedEscrow(uint256 unstakedEscrow);
/// @notice previous rewards period must be complete before changing the duration for the new period
error RewardsPeriodNotComplete();
/// @notice recovering the staking token is not allowed
error CannotRecoverStakingToken();
/// @notice recovering the usdc reward token is not allowed
error CannotRecoverRewardToken();
/// @notice error when user tries unstake during the cooldown period
/// @param canUnstakeAt timestamp when user can unstake
error MustWaitForUnlock(uint256 canUnstakeAt);
/// @notice error when trying to set a rewards duration that is too short
error RewardsDurationCannotBeZero();
/// @notice error when trying to set a cooldown period below the minimum
/// @param minCooldownPeriod minimum cooldown period
error CooldownPeriodTooLow(uint256 minCooldownPeriod);
/// @notice error when trying to set a cooldown period above the maximum
/// @param maxCooldownPeriod maximum cooldown period
error CooldownPeriodTooHigh(uint256 maxCooldownPeriod);
/// @notice the caller is not approved to take this action
error NotApproved();
/// @notice attempted to approve self as an operator
error CannotApproveSelf();
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface IStakingRewardsNotifier {
// Errors
/// @notice cannot set this value to the zero address
error ZeroAddress();
/// @notice OnlySupplySchedule can access this
error OnlySupplySchedule();
/// @notice Staking Rewards contract was already set
error AlreadySet();
// Mutative Functions
/// @notice set the StakingRewardsV2 contract
/// @param _stakingRewardsV2: address of the StakingRewardsV2 contract
function setStakingRewardsV2(address _stakingRewardsV2) external;
/// @notice notify the StakingRewardsV2 contract of the reward amount
/// @param mintedAmount: amount of rewards minted
/// @dev This function will be called on a periodic basis by the SupplySchedule contract
/// @dev mintedAmount is not used but cannot be removed from the function signature
/// as it is called by SupplySchedule which is immutable and expects to pass this value
function notifyRewardAmount(uint256 mintedAmount) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IRewardEscrowV2 {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice A vesting entry contains the data for each escrow NFT
struct VestingEntry {
// The amount of KWENTA stored in this vesting entry
uint256 escrowAmount;
// The length of time until the entry is fully matured
uint256 duration;
// The time at which the entry will be fully matured
uint256 endTime;
// The percentage fee for vesting immediately
// The actual penalty decreases linearly with time until it reaches 0 at block.timestamp=endTime
uint256 earlyVestingFee;
}
/// @notice The same as VestingEntry but packed to fit in a single slot
struct VestingEntryPacked {
uint144 escrowAmount;
uint40 duration;
uint64 endTime;
uint8 earlyVestingFee;
}
/// @notice Helper struct for getVestingSchedules view
struct VestingEntryWithID {
// The amount of KWENTA stored in this vesting entry
uint256 escrowAmount;
// The unique ID of this escrow entry NFT
uint256 entryID;
// The time at which the entry will be fully matured
uint256 endTime;
}
/*///////////////////////////////////////////////////////////////
INITIALIZER
///////////////////////////////////////////////////////////////*/
/// @notice Initializes the contract
/// @param _owner The address of the owner of this contract
/// @dev this function should be called via proxy, not via direct contract interaction
function initialize(address _owner) external;
/*///////////////////////////////////////////////////////////////
SETTERS
///////////////////////////////////////////////////////////////*/
/// @notice Function used to define the StakingRewardsV2 contract address to use
/// @param _stakingRewards The address of the StakingRewardsV2 contract
/// @dev This function can only be called once
function setStakingRewards(address _stakingRewards) external;
/// @notice Function used to define the EscrowMigrator contract address to use
/// @param _escrowMigrator The address of the EscrowMigrator contract
function setEscrowMigrator(address _escrowMigrator) external;
/// @notice Function used to define the TreasuryDAO address to use
/// @param _treasuryDAO The address of the TreasuryDAO
/// @dev This function can only be called multiple times
function setTreasuryDAO(address _treasuryDAO) external;
/*///////////////////////////////////////////////////////////////
VIEWS
///////////////////////////////////////////////////////////////*/
/// @notice Minimum early vesting fee
/// @dev this must be high enought to prevent governance attacks where the user
/// can set the early vesting fee to a very low number, stake, vote, then withdraw
/// via vesting which avoids the unstaking cooldown
function MINIMUM_EARLY_VESTING_FEE() external view returns (uint256);
/// @notice Default early vesting fee
/// @dev This is the default fee applied for early vesting
function DEFAULT_EARLY_VESTING_FEE() external view returns (uint256);
/// @notice Default escrow duration
/// @dev This is the default duration for escrow
function DEFAULT_DURATION() external view returns (uint256);
/// @notice helper function to return kwenta address
function getKwentaAddress() external view returns (address);
/// @notice A simple alias to totalEscrowedAccountBalance
function escrowedBalanceOf(address _account) external view returns (uint256);
/// @notice Get the amount of escrowed kwenta that is not staked for a given account
function unstakedEscrowedBalanceOf(address _account) external view returns (uint256);
/// @notice Get the details of a given vesting entry
/// @param _entryID The id of the vesting entry.
/// @return endTime the vesting entry object
/// @return escrowAmount rate per second emission.
/// @return duration the duration of the vesting entry.
/// @return earlyVestingFee the early vesting fee of the vesting entry.
function getVestingEntry(uint256 _entryID)
external
view
returns (uint256, uint256, uint256, uint256);
/// @notice Get the vesting entries for a given account
/// @param _account The account to get the vesting entries for
/// @param _index The index of the first vesting entry to get
/// @param _pageSize The number of vesting entries to get
/// @return vestingEntries the list of vesting entries with ids
function getVestingSchedules(address _account, uint256 _index, uint256 _pageSize)
external
view
returns (VestingEntryWithID[] memory);
/// @notice Get the vesting entries for a given account
/// @param _account The account to get the vesting entries for
/// @param _index The index of the first vesting entry to get
/// @param _pageSize The number of vesting entries to get
/// @return vestingEntries the list of vesting entry ids
function getAccountVestingEntryIDs(address _account, uint256 _index, uint256 _pageSize)
external
view
returns (uint256[] memory);
/// @notice Get the amount that can be vested now for a set of vesting entries
/// @param _entryIDs The ids of the vesting entries to get the quantity for
/// @return total The total amount that can be vested for these entries
/// @return totalFee The total amount of fees that will be paid for these vesting entries
function getVestingQuantity(uint256[] calldata _entryIDs)
external
view
returns (uint256, uint256);
/// @notice Get the amount that can be vested now for a given vesting entry
/// @param _entryID The id of the vesting entry to get the quantity for
/// @return quantity The total amount that can be vested for this entry
/// @return totalFee The total amount of fees that will be paid for this vesting entry
function getVestingEntryClaimable(uint256 _entryID) external view returns (uint256, uint256);
/*///////////////////////////////////////////////////////////////
MUTATIVE FUNCTIONS
///////////////////////////////////////////////////////////////*/
/// @notice Vest escrowed amounts that are claimable - allows users to vest their vesting entries based on msg.sender
/// @param _entryIDs The ids of the vesting entries to vest
function vest(uint256[] calldata _entryIDs) external;
/// @notice Utilized by the escrow migrator contract to transfer V1 escrow
/// @param _account The account to import the escrow entry to
/// @param entryToImport The vesting entry to import
function importEscrowEntry(address _account, VestingEntry memory entryToImport) external;
/// @notice Create an escrow entry to lock KWENTA for a given duration in seconds
/// @param _beneficiary The account that will be able to withdraw the escrowed amount
/// @param _deposit The amount of KWENTA to escrow
/// @param _duration The duration in seconds to lock the KWENTA for
/// @param _earlyVestingFee The fee to apply if the escrowed amount is withdrawn before the end of the vesting period
/// @dev the early vesting fee decreases linearly over the vesting period
/// @dev This call expects that the depositor (msg.sender) has already approved the Reward escrow contract
/// to spend the the amount being escrowed.
function createEscrowEntry(
address _beneficiary,
uint256 _deposit,
uint256 _duration,
uint256 _earlyVestingFee
) external;
/// @notice Add a new vesting entry at a given time and quantity to an account's schedule.
/// @dev A call to this should accompany a previous successful call to kwenta.transfer(rewardEscrow, amount),
/// to ensure that when the funds are withdrawn, there is enough balance.
/// This is only callable by the staking rewards contract
/// The duration defaults to 1 year, and the early vesting fee to 90%
/// @param _account The account to append a new vesting entry to.
/// @param _quantity The quantity of KWENTA that will be escrowed.
function appendVestingEntry(address _account, uint256 _quantity) external;
/// @notice Transfer multiple entries from one account to another
/// Sufficient escrowed KWENTA must be unstaked for the transfer to succeed
/// @param _from The account to transfer the entries from
/// @param _to The account to transfer the entries to
/// @param _entryIDs a list of the ids of the entries to transfer
function bulkTransferFrom(address _from, address _to, uint256[] calldata _entryIDs) external;
/// @dev Triggers stopped state
function pauseRewardEscrow() external;
/// @dev Returns to normal state.
function unpauseRewardEscrow() external;
/*///////////////////////////////////////////////////////////////
EVENTS
///////////////////////////////////////////////////////////////*/
/// @notice emitted when an escrow entry is vested
/// @param beneficiary The account that was vested to
/// @param value The amount of KWENTA that was vested
event Vested(address indexed beneficiary, uint256 value);
/// @notice emitted when an escrow entry is created
/// @param beneficiary The account that gets the entry
/// @param value The amount of KWENTA that was escrowed
/// @param duration The duration in seconds of the vesting entry
/// @param entryID The id of the vesting entry
/// @param earlyVestingFee The early vesting fee of the vesting entry
event VestingEntryCreated(
address indexed beneficiary,
uint256 value,
uint256 duration,
uint256 entryID,
uint256 earlyVestingFee
);
/// @notice emitted when the staking rewards contract is set
/// @param stakingRewards The address of the staking rewards contract
event StakingRewardsSet(address stakingRewards);
/// @notice emitted when the escrow migrator contract is set
/// @param escrowMigrator The address of the escrow migrator contract
event EscrowMigratorSet(address escrowMigrator);
/// @notice emitted when the treasury DAO is set
/// @param treasuryDAO The address of the treasury DAO
event TreasuryDAOSet(address treasuryDAO);
/// @notice emitted when the early vest fee is sent to the treasury and notifier
/// @param amountToTreasury The amount of KWENTA sent to the treasury
/// @param amountToNotifier The amount of KWENTA sent to the notifier
event EarlyVestFeeSent(uint256 amountToTreasury, uint256 amountToNotifier);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when attempting to bulk transfer from and to the same address
error CannotTransferToSelf();
/// @notice Insufficient unstaked escrow to facilitate transfer
/// @param escrowAmount the amount of escrow attempted to transfer
/// @param unstakedBalance the amount of unstaked escrow available
error InsufficientUnstakedBalance(uint256 escrowAmount, uint256 unstakedBalance);
/// @notice Attempted to set entry early vesting fee beyond 100%
error EarlyVestingFeeTooHigh();
/// @notice cannot mint entries with early vesting fee below the minimum
error EarlyVestingFeeTooLow();
/// @notice error someone other than staking rewards calls an onlyStakingRewards function
error OnlyStakingRewards();
/// @notice error someone other than escrow migrator calls an onlyEscrowMigrator function
error OnlyEscrowMigrator();
/// @notice staking rewards is only allowed to be set once
error StakingRewardsAlreadySet();
/// @notice cannot set this value to the zero address
error ZeroAddress();
/// @notice cannot mint entries with zero escrow
error ZeroAmount();
/// @notice Cannot escrow with 0 duration OR above max_duration
error InvalidDuration();
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../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;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../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.
*
* By default, the owner account will be the one that deploys the contract. 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 {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @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) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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 {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @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 IERC1822ProxiableUpgradeable {
/**
* @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 v4.8.3) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.3) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.9._
*/
interface IERC1967Upgradeable {
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @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:
* ```
* 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(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 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
}
}
}{
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@ensdomains/=node_modules/@ensdomains/",
"@eth-optimism/=node_modules/@eth-optimism/",
"@openzeppelin/=node_modules/@openzeppelin/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"hardhat-deploy/=node_modules/hardhat-deploy/",
"hardhat/=node_modules/hardhat/",
"openzeppelin-solidity-2.3.0/=node_modules/openzeppelin-solidity-2.3.0/",
"synthetix/=node_modules/synthetix/",
"truffle/=node_modules/truffle/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_kwenta","type":"address"},{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_rewardEscrow","type":"address"},{"internalType":"address","name":"_rewardsNotifier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AmountZero","type":"error"},{"inputs":[],"name":"CannotApproveSelf","type":"error"},{"inputs":[],"name":"CannotRecoverRewardToken","type":"error"},{"inputs":[],"name":"CannotRecoverStakingToken","type":"error"},{"inputs":[{"internalType":"uint256","name":"maxCooldownPeriod","type":"uint256"}],"name":"CooldownPeriodTooHigh","type":"error"},{"inputs":[{"internalType":"uint256","name":"minCooldownPeriod","type":"uint256"}],"name":"CooldownPeriodTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"availableBalance","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"unstakedEscrow","type":"uint256"}],"name":"InsufficientUnstakedEscrow","type":"error"},{"inputs":[{"internalType":"uint256","name":"canUnstakeAt","type":"uint256"}],"name":"MustWaitForUnlock","type":"error"},{"inputs":[],"name":"NotApproved","type":"error"},{"inputs":[],"name":"OnlyRewardEscrow","type":"error"},{"inputs":[],"name":"OnlyRewardsNotifier","type":"error"},{"inputs":[],"name":"RewardsDurationCannotBeZero","type":"error"},{"inputs":[],"name":"RewardsPeriodNotComplete","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cooldownPeriod","type":"uint256"}],"name":"CooldownPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EscrowStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EscrowUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"OperatorApproved","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":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardUsdc","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaidUSDC","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","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":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"MAX_COOLDOWN_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_COOLDOWN_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"approveOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"balanceAtTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"balancesCheckpoints","outputs":[{"internalType":"uint64","name":"ts","type":"uint64"},{"internalType":"uint64","name":"blk","type":"uint64"},{"internalType":"uint128","name":"value","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balancesCheckpointsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"compoundOnBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cooldownPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"earnedUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"escrowedBalanceAtTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"escrowedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"escrowedBalancesCheckpoints","outputs":[{"internalType":"uint64","name":"ts","type":"uint64"},{"internalType":"uint64","name":"blk","type":"uint64"},{"internalType":"uint128","name":"value","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"escrowedBalancesCheckpointsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardForDurationUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getRewardOnBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"kwenta","outputs":[{"internalType":"contract IKwenta","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"nonEscrowedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reward","type":"uint256"},{"internalType":"uint256","name":"_rewardUsdc","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"operatorApprovals","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseStakingRewards","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":[],"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":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardEscrow","outputs":[{"internalType":"contract IRewardEscrowV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStoredUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRateUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsNotifier","outputs":[{"internalType":"contract IStakingRewardsNotifier","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardsUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cooldownPeriod","type":"uint256"}],"name":"setCooldownPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeEscrowOnBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"totalSupplyAtTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalSupplyCheckpoints","outputs":[{"internalType":"uint64","name":"ts","type":"uint64"},{"internalType":"uint64","name":"blk","type":"uint64"},{"internalType":"uint128","name":"value","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupplyCheckpointsLength","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":"unpauseStakingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstakeEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstakeEscrowSkipCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"unstakedEscrowedBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","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":[],"name":"usdc","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userLastStakeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaidUSDC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x610120604052306080523480156200001657600080fd5b5060405162004346380380620043468339810160408190526200003991620001a9565b6001600160a01b03841615806200005757506001600160a01b038316155b806200006a57506001600160a01b038216155b806200007d57506001600160a01b038116155b156200009c5760405163d92e233d60e01b815260040160405180910390fd5b620000a6620000ca565b6001600160a01b0393841660a05291831661010052821660c0521660e05262000206565b600054610100900460ff1615620001375760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811610156200018a576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b0381168114620001a457600080fd5b919050565b60008060008060808587031215620001c057600080fd5b620001cb856200018c565b9350620001db602086016200018c565b9250620001eb604086016200018c565b9150620001fb606086016200018c565b905092959194509250565b60805160a05160c05160e05161010051614092620002b4600039600081816106d901528181611c4f015261376c015260008181610c510152612505015260008181610a6f0152818161237001528181612b2b015281816135380152613621015260008181610a0d015281816112ef01528181611bca01528181611f05015261356701526000818161138f0152818161143f0152818161159f0152818161164f01526117bc01526140926000f3fe6080604052600436106104495760003560e01c806380faa57d11610243578063cc1a378f11610143578063e5eab5c0116100bb578063f0d3570d1161008a578063f2fde38b1161006f578063f2fde38b14610d23578063f56e895d14610d43578063f69e204614610d5a57600080fd5b8063f0d3570d14610cdf578063f2239df914610cf557600080fd5b8063e5eab5c014610c73578063e9fad8ee14610c93578063ebe2b12b14610ca8578063eddaee9214610cbf57600080fd5b8063daf3807311610112578063df136d65116100f7578063df136d6514610bfd578063e30c397814610c14578063e509584314610c3f57600080fd5b8063daf3807314610bbd578063de852ab614610bdd57600080fd5b8063cc1a378f14610b48578063cd3daf9d14610b68578063cf58193814610b7d578063d2dcd93314610b9d57600080fd5b80639034802b116101d6578063a86c3cde116101a5578063c4d66de81161018a578063c4d66de814610af1578063c6f543d714610b11578063c8f33c9114610b3157600080fd5b8063a86c3cde14610ab1578063b66e4cdf14610ad157600080fd5b80639034802b146109fb57806397cd023f14610a2f578063a430be6c14610a5d578063a694fc3a14610a9157600080fd5b806389997f9a1161021257806389997f9a146109765780638af8ada81461098b5780638b876347146109a25780638da5cb5b146109d057600080fd5b806380faa57d1461090c57806383fd187e14610921578063865ab9af146109365780638980f11f1461095657600080fd5b80633e413bee1161034e5780635fce7445116102e1578063715018a6116102b05780637b0a47ee116102955780637b0a47ee146108b55780637f94e8ff146108cc57806380ea3de1146108ec57600080fd5b8063715018a61461088b57806379ba5097146108a057600080fd5b80635fce74451461081f5780636022e0711461083f5780636079916f1461085657806370a082311461086b57600080fd5b806352d1902d1161031d57806352d1902d14610781578063556d1a09146107965780635c975abb146107ae5780635f7cfe5d146107c657600080fd5b80633e413bee146106c75780634d9898c6146107205780634f1ef2861461074e578063514a16c91461076157600080fd5b80631c210ebe116103e157806329b35ab6116103b05780633659cfe6116103955780633659cfe61461067b578063386a95251461069b5780633d18b912146106b257600080fd5b806329b35ab61461063b5780632e17de781461065b57600080fd5b80631c210ebe14610571578063218e626e146105b5578063246132f9146105d5578063299f8324146105f757600080fd5b80630d95e0541161041d5780630d95e054146104e65780630e89e3f31461053257806318160ddd146105475780631c1f78eb1461055c57600080fd5b80628cc2621461044e57806304646a4914610481578063057a601b146104985780630700037d146104b8575b600080fd5b34801561045a57600080fd5b5061046e610469366004613c62565b610d6f565b6040519081526020015b60405180910390f35b34801561048d57600080fd5b5061046e6101355481565b3480156104a457600080fd5b5061046e6104b3366004613c62565b610df4565b3480156104c457600080fd5b5061046e6104d3366004613c62565b6101376020526000908152604090205481565b3480156104f257600080fd5b50610522610501366004613c7d565b61013960209081526000928352604080842090915290825290205460ff1681565b6040519015158152602001610478565b34801561053e57600080fd5b5061046e610e8b565b34801561055357600080fd5b5061046e610ea4565b34801561056857600080fd5b5061046e610f1a565b34801561057d57600080fd5b5061046e61058c366004613c62565b73ffffffffffffffffffffffffffffffffffffffff16600090815261012d602052604090205490565b3480156105c157600080fd5b5061046e6105d0366004613c62565b610f2e565b3480156105e157600080fd5b506105f56105f0366004613cb0565b610f84565b005b34801561060357600080fd5b5061046e610612366004613c62565b73ffffffffffffffffffffffffffffffffffffffff16600090815261012e602052604090205490565b34801561064757600080fd5b506105f5610656366004613ce0565b6110b6565b34801561066757600080fd5b506105f5610676366004613d17565b6111a8565b34801561068757600080fd5b506105f5610696366004613c62565b611378565b3480156106a757600080fd5b5061046e6101325481565b3480156106be57600080fd5b506105f561157d565b3480156106d357600080fd5b506106fb7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610478565b34801561072c57600080fd5b5061046e61073b366004613c62565b61013c6020526000908152604090205481565b6105f561075c366004613d5f565b611588565b34801561076d57600080fd5b5061046e61077c366004613c62565b61177e565b34801561078d57600080fd5b5061046e6117a2565b3480156107a257600080fd5b5061046e6301dfe20081565b3480156107ba57600080fd5b5060975460ff16610522565b3480156107d257600080fd5b506107e66107e1366004613e3f565b61188e565b6040805167ffffffffffffffff94851681529390921660208401526fffffffffffffffffffffffffffffffff1690820152606001610478565b34801561082b57600080fd5b506105f561083a366004613c62565b6118fd565b34801561084b57600080fd5b5061046e61013b5481565b34801561086257600080fd5b506105f5611910565b34801561087757600080fd5b5061046e610886366004613c62565b611920565b34801561089757600080fd5b506105f5611963565b3480156108ac57600080fd5b506105f5611975565b3480156108c157600080fd5b5061046e6101315481565b3480156108d857600080fd5b506105f56108e7366004613e3f565b611a27565b3480156108f857600080fd5b506105f5610907366004613d17565b611a39565b34801561091857600080fd5b5061046e611b04565b34801561092d57600080fd5b5061046e611b1d565b34801561094257600080fd5b5061046e610951366004613e3f565b611b90565b34801561096257600080fd5b506105f5610971366004613e3f565b611bc0565b34801561098257600080fd5b506105f5611df8565b34801561099757600080fd5b5061046e61013a5481565b3480156109ae57600080fd5b5061046e6109bd366004613c62565b6101366020526000908152604090205481565b3480156109dc57600080fd5b5060335473ffffffffffffffffffffffffffffffffffffffff166106fb565b348015610a0757600080fd5b506106fb7f000000000000000000000000000000000000000000000000000000000000000081565b348015610a3b57600080fd5b5061046e610a4a366004613c62565b6101386020526000908152604090205481565b348015610a6957600080fd5b506106fb7f000000000000000000000000000000000000000000000000000000000000000081565b348015610a9d57600080fd5b506105f5610aac366004613d17565b611e08565b348015610abd57600080fd5b506105f5610acc366004613d17565b611f49565b348015610add57600080fd5b506107e6610aec366004613d17565b611f5d565b348015610afd57600080fd5b506105f5610b0c366004613c62565b611fbf565b348015610b1d57600080fd5b506105f5610b2c366004613e3f565b6121c0565b348015610b3d57600080fd5b5061046e6101335481565b348015610b5457600080fd5b506105f5610b63366004613d17565b6121d4565b348015610b7457600080fd5b5061046e612288565b348015610b8957600080fd5b506107e6610b98366004613e3f565b6122f5565b348015610ba957600080fd5b5061046e610bb8366004613d17565b612312565b348015610bc957600080fd5b5061046e610bd8366004613c62565b612320565b348015610be957600080fd5b506105f5610bf8366004613c62565b6123db565b348015610c0957600080fd5b5061046e6101345481565b348015610c2057600080fd5b5060655473ffffffffffffffffffffffffffffffffffffffff166106fb565b348015610c4b57600080fd5b506106fb7f000000000000000000000000000000000000000000000000000000000000000081565b348015610c7f57600080fd5b5061046e610c8e366004613e3f565b6123ee565b348015610c9f57600080fd5b506105f561241e565b348015610cb457600080fd5b5061046e6101305481565b348015610ccb57600080fd5b506105f5610cda366004613d17565b61242a565b348015610ceb57600080fd5b5061012f5461046e565b348015610d0157600080fd5b5061046e610d10366004613c62565b61013d6020526000908152604090205481565b348015610d2f57600080fd5b506105f5610d3e366004613c62565b612434565b348015610d4f57600080fd5b5061046e62093a8081565b348015610d6657600080fd5b506105f56124e4565b600080610d7b83611920565b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013760209081526040808320546101369092529091205491925090670de0b6b3a764000090610dc5612288565b610dcf9190613e98565b610dd99084613eab565b610de39190613ec2565b610ded9190613efd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815261012e6020526040812080548015610e6e57816001820381548110610e3757610e37613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16610e71565b60005b6fffffffffffffffffffffffffffffffff16949350505050565b60006101325461013a54610e9f9190613eab565b905090565b61012f546000908015610eff5761012f6001820381548110610ec857610ec8613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16610f02565b60005b6fffffffffffffffffffffffffffffffff1691505090565b60006101325461013154610e9f9190613eab565b600080610f3a83611920565b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013d602090815260408083205461013c9092529091205491925090670de0b6b3a764000090610dc5611b1d565b610f8c6124ed565b6000610f978161255c565b610130544210610fd95761013254610faf9084613ec2565b6101315561013254610fc664e8d4a5100084613eab565b610fd09190613ec2565b61013a55611060565b60004261013054610fea9190613e98565b905060006101315482610ffd9190613eab565b6101325490915061100e8287613efd565b6110189190613ec2565b6101315561013a5460009061102d9084613eab565b610132549091508161104464e8d4a5100088613eab565b61104e9190613efd565b6110589190613ec2565b61013a555050505b426101338190556101325461107491613efd565b6101305560408051848152602081018490527f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55910160405180910390a1505050565b3373ffffffffffffffffffffffffffffffffffffffff831603611105576040517f2333d00d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526101396020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016861515908117909155815194855291840192909252908201527f42ef3a6445090af5f522bf393e8d432b01eb65949f6e2bca70984e3630b63777906060015b60405180910390a15050565b6111b0612627565b336111ba8161255c565b336111c481612694565b826000036111fe576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112093361177e565b90508084111561124d576040517f92665351000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b61126884611259610ea4565b6112639190613e98565b612709565b611285338561127633611920565b6112809190613e98565b612715565b60405184815233907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a26040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018590527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af115801561134d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113719190613f3f565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016300361143d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611244565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166114b27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611244565b61155e81612745565b6040805160008082526020820190925261157a9183919061274d565b50565b6115863361294c565b565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016300361164d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611244565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166116c27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611765576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611244565b61176e82612745565b61177a8282600161274d565b5050565b600061178982610df4565b61179283611920565b61179c9190613e98565b92915050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401611244565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b61012e60205281600052604060002081815481106118ab57600080fd5b60009182526020909120015467ffffffffffffffff808216935068010000000000000000820416915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1683565b8061190781612956565b61177a826129c1565b6119186129dc565b611586612a5d565b73ffffffffffffffffffffffffffffffffffffffff8116600090815261012d6020526040812080548015610e6e57816001820381548110610e3757610e37613f10565b61196b6129dc565b6115866000612ae2565b606554339073ffffffffffffffffffffffffffffffffffffffff168114611a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e657200000000000000000000000000000000000000000000006064820152608401611244565b61157a81612ae2565b611a2f612b13565b61177a8282612b82565b611a416129dc565b62093a80811015611a83576040517fadc45a1700000000000000000000000000000000000000000000000000000000815262093a806004820152602401611244565b6301dfe200811115611ac7576040517fa39fe6440000000000000000000000000000000000000000000000000000000081526301dfe2006004820152602401611244565b6101358190556040518181527f3b897fd6944545fcb6a5d5b058781d763169157f8559ca1a7f3276b981d09971906020015b60405180910390a150565b6000610130544210611b1857506101305490565b504290565b600080611b28610ea4565b905080600003611b3b57505061013b5490565b8061013a5461013354611b4c611b04565b611b569190613e98565b611b609190613eab565b611b7290670de0b6b3a7640000613eab565b611b7c9190613ec2565b61013b54611b8a9190613efd565b91505090565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012d60205260408120610ded9083612ca4565b611bc86129dc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c4d576040517f1b81380300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611cd2576040517fe4ea100b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a18173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb611d5c60335473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044015b6020604051808303816000875af1158015611dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df39190613f3f565b505050565b611e006129dc565b611586612e56565b611e10612627565b33611e1a8161255c565b81600003611e54576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815261013860205260409020429055611e7d82611e73610ea4565b6112639190613efd565b611e953383611e8b33611920565b6112809190613efd565b60405182815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200160405180910390a26040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018390527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906323b872dd90606401611db0565b33611f5381612694565b61177a3383612b82565b61012f8181548110611f6e57600080fd5b60009182526020909120015467ffffffffffffffff8082169250680100000000000000008204169070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1683565b600054610100900460ff1615808015611fdf5750600054600160ff909116105b80611ff95750303b158015611ff9575060005460ff166001145b612085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401611244565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156120e357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff8216612130576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612138612ead565b612140612f4c565b612148612feb565b61215182612ae2565b62093a80610132556212750061013555801561177a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161119c565b816121ca81612956565b611df38383613082565b6121dc6129dc565b610130544211612218576040517f5691d11300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003612252576040517ffff9f93e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101328190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001611af9565b600080612293610ea4565b9050806000036122a65750506101345490565b8061013154610133546122b7611b04565b6122c19190613e98565b6122cb9190613eab565b6122dd90670de0b6b3a7640000613eab565b6122e79190613ec2565b61013454611b8a9190613efd565b61012d60205281600052604060002081815481106118ab57600080fd5b600061179c61012f83612ca4565b600061232b82610df4565b6040517f057a601b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063057a601b90602401602060405180830381865afa1580156123b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117929190613f5c565b806123e581612956565b61177a8261294c565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012e60205260408120610ded9083612ca4565b61157d6106763361177e565b61157a3382613082565b61243c6129dc565b6065805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915561249f60335473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b611586336129c1565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611586576040517f4dd89e9400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612564612288565b61013455612570611b1d565b61013b5561257c611b04565b6101335573ffffffffffffffffffffffffffffffffffffffff81161561157a576125a581610d6f565b73ffffffffffffffffffffffffffffffffffffffff82166000908152610137602090815260408083209390935561013454610136909152919020556125e981610f2e565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261013d602090815260408083209390935561013b5461013c9091529190205550565b60975460ff1615611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611244565b6101355473ffffffffffffffffffffffffffffffffffffffff82166000908152610138602052604081205490916126ca91613efd565b90504281111561177a576040517f098aefdd00000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b61157a61012f826131c9565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012d6020526040902061177a90826131c9565b61157a6129dc565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561278057611df38361332a565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612805575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261280291810190613f5c565b60015b612891576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401611244565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612940576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401611244565b50611df3838383613434565b61157a8182613459565b73ffffffffffffffffffffffffffffffffffffffff811660009081526101396020908152604080832033845290915290205460ff1661157a576040517fc19f17a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6129ca8161294c565b61157a816129d783612320565b613082565b60335473ffffffffffffffffffffffffffffffffffffffff163314611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611244565b612a65612627565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ab83390565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b606580547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561157a816137e1565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611586576040517f450d292900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b8a612627565b81612b948161255c565b81600003612bce576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612bd984610df4565b905080831115612c18576040517f9266535100000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b612c26848461127687611920565b612c438484612c3487610df4565b612c3e9190613e98565b613858565b612c4f83611259610ea4565b6040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018590527fbd0d30ac1729a6f57b09c27c8f39102f2704fbbf708747dcd198e45cf27f5282910160405180910390a150505050565b8154600090808203612cba57600091505061179c565b600080612cc8600184613e98565b905084868381548110612cdd57612cdd613f10565b60009182526020909120015467ffffffffffffffff161115612d05576000935050505061179c565b84868281548110612d1857612d18613f10565b60009182526020909120015467ffffffffffffffff1611612d8257858181548110612d4557612d45613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16935061179c92505050565b81811115612df95760006002612d988484613efd565b612da3906001613efd565b612dad9190613ec2565b905085878281548110612dc257612dc2613f10565b60009182526020909120015467ffffffffffffffff1611612de557809250612df3565b612df0600182613e98565b91505b50612d82565b808214612e0857612e08613f75565b858281548110612e1a57612e1a613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff169695505050505050565b612e5e613888565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33612ab8565b600054610100900460ff16612f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b6115866138f4565b600054610100900460ff16612fe3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b611586613994565b600054610100900460ff16611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b61308a612627565b816130948161255c565b816000036130ce576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006130d984612320565b905080831115613118576040517f012801c000000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b73ffffffffffffffffffffffffffffffffffffffff841660009081526101386020526040902042905561314f8484611e8b82611920565b613167848461315d87610df4565b612c3e9190613efd565b61317383611e73610ea4565b8373ffffffffffffffffffffffffffffffffffffffff167f945856e466506640ce955f1ec0de49513761175bad680d8503f7c8d45beabb20846040516131bb91815260200190565b60405180910390a250505050565b815460008115613203578360018303815481106131e8576131e8613f10565b60009182526020909120015467ffffffffffffffff16613206565b60005b67ffffffffffffffff1690504281146132d1576040805160608101825267ffffffffffffffff428116825243811660208084019182526fffffffffffffffffffffffffffffffff8089169585019586528954600181018b5560008b81529290922094519490910180549251955182167001000000000000000000000000000000000295841668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909316949093169390931717909116919091179055613324565b828460018403815481106132e7576132e7613f10565b600091825260209091200180546fffffffffffffffffffffffffffffffff9283167001000000000000000000000000000000000292169190911790555b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6133ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401611244565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61343d83613a55565b60008251118061344a5750805b15611df3576133248383613aa2565b613461612627565b8161346b8161255c565b73ffffffffffffffffffffffffffffffffffffffff831660009081526101376020526040902054801561367e5773ffffffffffffffffffffffffffffffffffffffff84166000818152610137602052604080822091909155517fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486906134f39084815260200190565b60405180910390a26040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af11580156135b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d49190613f3f565b506040517fb5ddb9c700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063b5ddb9c790604401600060405180830381600087803b15801561366557600080fd5b505af1158015613679573d6000803e3d6000fd5b505050505b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013d60205260408120546136b59064e8d4a5100090613ec2565b905080156113715773ffffffffffffffffffffffffffffffffffffffff8516600081815261013d602052604080822091909155517f816c86b1a5030bb39cbd10a56660a0fa4c5d0a682a45f2e865639083e61f439b906137189084815260200190565b60405180910390a26040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af11580156137b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d99190613f3f565b505050505050565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012e6020526040902061177a90826131c9565b60975460ff16611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611244565b600054610100900460ff1661398b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b61158633612ae2565b600054610100900460ff16613a2b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b613a5e8161332a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606073ffffffffffffffffffffffffffffffffffffffff83163b613b48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401611244565b6000808473ffffffffffffffffffffffffffffffffffffffff1684604051613b709190613fc8565b600060405180830381855af49150503d8060008114613bab576040519150601f19603f3d011682016040523d82523d6000602084013e613bb0565b606091505b5091509150613bd8828260405180606001604052806027815260200161403660279139613be1565b95945050505050565b60608315613bf0575081610ded565b610ded8383815115613c055781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112449190613fe4565b803573ffffffffffffffffffffffffffffffffffffffff81168114613c5d57600080fd5b919050565b600060208284031215613c7457600080fd5b610ded82613c39565b60008060408385031215613c9057600080fd5b613c9983613c39565b9150613ca760208401613c39565b90509250929050565b60008060408385031215613cc357600080fd5b50508035926020909101359150565b801515811461157a57600080fd5b60008060408385031215613cf357600080fd5b613cfc83613c39565b91506020830135613d0c81613cd2565b809150509250929050565b600060208284031215613d2957600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215613d7257600080fd5b613d7b83613c39565b9150602083013567ffffffffffffffff80821115613d9857600080fd5b818501915085601f830112613dac57600080fd5b813581811115613dbe57613dbe613d30565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613e0457613e04613d30565b81604052828152886020848701011115613e1d57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008060408385031215613e5257600080fd5b613e5b83613c39565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561179c5761179c613e69565b808202811582820484141761179c5761179c613e69565b600082613ef8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b8082018082111561179c5761179c613e69565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613f5157600080fd5b8151610ded81613cd2565b600060208284031215613f6e57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b60005b83811015613fbf578181015183820152602001613fa7565b50506000910152565b60008251613fda818460208701613fa4565b9190910192915050565b6020815260008251806020840152614003816040850160208701613fa4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209cb43e413099481083a979f526e4d11b338687b52660aad553ea5b0b3f3a57bb64736f6c63430008130033000000000000000000000000920cf626a271321c151d027030d5d08af699456b0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c56000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe4
Deployed Bytecode
0x6080604052600436106104495760003560e01c806380faa57d11610243578063cc1a378f11610143578063e5eab5c0116100bb578063f0d3570d1161008a578063f2fde38b1161006f578063f2fde38b14610d23578063f56e895d14610d43578063f69e204614610d5a57600080fd5b8063f0d3570d14610cdf578063f2239df914610cf557600080fd5b8063e5eab5c014610c73578063e9fad8ee14610c93578063ebe2b12b14610ca8578063eddaee9214610cbf57600080fd5b8063daf3807311610112578063df136d65116100f7578063df136d6514610bfd578063e30c397814610c14578063e509584314610c3f57600080fd5b8063daf3807314610bbd578063de852ab614610bdd57600080fd5b8063cc1a378f14610b48578063cd3daf9d14610b68578063cf58193814610b7d578063d2dcd93314610b9d57600080fd5b80639034802b116101d6578063a86c3cde116101a5578063c4d66de81161018a578063c4d66de814610af1578063c6f543d714610b11578063c8f33c9114610b3157600080fd5b8063a86c3cde14610ab1578063b66e4cdf14610ad157600080fd5b80639034802b146109fb57806397cd023f14610a2f578063a430be6c14610a5d578063a694fc3a14610a9157600080fd5b806389997f9a1161021257806389997f9a146109765780638af8ada81461098b5780638b876347146109a25780638da5cb5b146109d057600080fd5b806380faa57d1461090c57806383fd187e14610921578063865ab9af146109365780638980f11f1461095657600080fd5b80633e413bee1161034e5780635fce7445116102e1578063715018a6116102b05780637b0a47ee116102955780637b0a47ee146108b55780637f94e8ff146108cc57806380ea3de1146108ec57600080fd5b8063715018a61461088b57806379ba5097146108a057600080fd5b80635fce74451461081f5780636022e0711461083f5780636079916f1461085657806370a082311461086b57600080fd5b806352d1902d1161031d57806352d1902d14610781578063556d1a09146107965780635c975abb146107ae5780635f7cfe5d146107c657600080fd5b80633e413bee146106c75780634d9898c6146107205780634f1ef2861461074e578063514a16c91461076157600080fd5b80631c210ebe116103e157806329b35ab6116103b05780633659cfe6116103955780633659cfe61461067b578063386a95251461069b5780633d18b912146106b257600080fd5b806329b35ab61461063b5780632e17de781461065b57600080fd5b80631c210ebe14610571578063218e626e146105b5578063246132f9146105d5578063299f8324146105f757600080fd5b80630d95e0541161041d5780630d95e054146104e65780630e89e3f31461053257806318160ddd146105475780631c1f78eb1461055c57600080fd5b80628cc2621461044e57806304646a4914610481578063057a601b146104985780630700037d146104b8575b600080fd5b34801561045a57600080fd5b5061046e610469366004613c62565b610d6f565b6040519081526020015b60405180910390f35b34801561048d57600080fd5b5061046e6101355481565b3480156104a457600080fd5b5061046e6104b3366004613c62565b610df4565b3480156104c457600080fd5b5061046e6104d3366004613c62565b6101376020526000908152604090205481565b3480156104f257600080fd5b50610522610501366004613c7d565b61013960209081526000928352604080842090915290825290205460ff1681565b6040519015158152602001610478565b34801561053e57600080fd5b5061046e610e8b565b34801561055357600080fd5b5061046e610ea4565b34801561056857600080fd5b5061046e610f1a565b34801561057d57600080fd5b5061046e61058c366004613c62565b73ffffffffffffffffffffffffffffffffffffffff16600090815261012d602052604090205490565b3480156105c157600080fd5b5061046e6105d0366004613c62565b610f2e565b3480156105e157600080fd5b506105f56105f0366004613cb0565b610f84565b005b34801561060357600080fd5b5061046e610612366004613c62565b73ffffffffffffffffffffffffffffffffffffffff16600090815261012e602052604090205490565b34801561064757600080fd5b506105f5610656366004613ce0565b6110b6565b34801561066757600080fd5b506105f5610676366004613d17565b6111a8565b34801561068757600080fd5b506105f5610696366004613c62565b611378565b3480156106a757600080fd5b5061046e6101325481565b3480156106be57600080fd5b506105f561157d565b3480156106d357600080fd5b506106fb7f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8581565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610478565b34801561072c57600080fd5b5061046e61073b366004613c62565b61013c6020526000908152604090205481565b6105f561075c366004613d5f565b611588565b34801561076d57600080fd5b5061046e61077c366004613c62565b61177e565b34801561078d57600080fd5b5061046e6117a2565b3480156107a257600080fd5b5061046e6301dfe20081565b3480156107ba57600080fd5b5060975460ff16610522565b3480156107d257600080fd5b506107e66107e1366004613e3f565b61188e565b6040805167ffffffffffffffff94851681529390921660208401526fffffffffffffffffffffffffffffffff1690820152606001610478565b34801561082b57600080fd5b506105f561083a366004613c62565b6118fd565b34801561084b57600080fd5b5061046e61013b5481565b34801561086257600080fd5b506105f5611910565b34801561087757600080fd5b5061046e610886366004613c62565b611920565b34801561089757600080fd5b506105f5611963565b3480156108ac57600080fd5b506105f5611975565b3480156108c157600080fd5b5061046e6101315481565b3480156108d857600080fd5b506105f56108e7366004613e3f565b611a27565b3480156108f857600080fd5b506105f5610907366004613d17565b611a39565b34801561091857600080fd5b5061046e611b04565b34801561092d57600080fd5b5061046e611b1d565b34801561094257600080fd5b5061046e610951366004613e3f565b611b90565b34801561096257600080fd5b506105f5610971366004613e3f565b611bc0565b34801561098257600080fd5b506105f5611df8565b34801561099757600080fd5b5061046e61013a5481565b3480156109ae57600080fd5b5061046e6109bd366004613c62565b6101366020526000908152604090205481565b3480156109dc57600080fd5b5060335473ffffffffffffffffffffffffffffffffffffffff166106fb565b348015610a0757600080fd5b506106fb7f000000000000000000000000920cf626a271321c151d027030d5d08af699456b81565b348015610a3b57600080fd5b5061046e610a4a366004613c62565b6101386020526000908152604090205481565b348015610a6957600080fd5b506106fb7f000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c5681565b348015610a9d57600080fd5b506105f5610aac366004613d17565b611e08565b348015610abd57600080fd5b506105f5610acc366004613d17565b611f49565b348015610add57600080fd5b506107e6610aec366004613d17565b611f5d565b348015610afd57600080fd5b506105f5610b0c366004613c62565b611fbf565b348015610b1d57600080fd5b506105f5610b2c366004613e3f565b6121c0565b348015610b3d57600080fd5b5061046e6101335481565b348015610b5457600080fd5b506105f5610b63366004613d17565b6121d4565b348015610b7457600080fd5b5061046e612288565b348015610b8957600080fd5b506107e6610b98366004613e3f565b6122f5565b348015610ba957600080fd5b5061046e610bb8366004613d17565b612312565b348015610bc957600080fd5b5061046e610bd8366004613c62565b612320565b348015610be957600080fd5b506105f5610bf8366004613c62565b6123db565b348015610c0957600080fd5b5061046e6101345481565b348015610c2057600080fd5b5060655473ffffffffffffffffffffffffffffffffffffffff166106fb565b348015610c4b57600080fd5b506106fb7f000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe481565b348015610c7f57600080fd5b5061046e610c8e366004613e3f565b6123ee565b348015610c9f57600080fd5b506105f561241e565b348015610cb457600080fd5b5061046e6101305481565b348015610ccb57600080fd5b506105f5610cda366004613d17565b61242a565b348015610ceb57600080fd5b5061012f5461046e565b348015610d0157600080fd5b5061046e610d10366004613c62565b61013d6020526000908152604090205481565b348015610d2f57600080fd5b506105f5610d3e366004613c62565b612434565b348015610d4f57600080fd5b5061046e62093a8081565b348015610d6657600080fd5b506105f56124e4565b600080610d7b83611920565b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013760209081526040808320546101369092529091205491925090670de0b6b3a764000090610dc5612288565b610dcf9190613e98565b610dd99084613eab565b610de39190613ec2565b610ded9190613efd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815261012e6020526040812080548015610e6e57816001820381548110610e3757610e37613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16610e71565b60005b6fffffffffffffffffffffffffffffffff16949350505050565b60006101325461013a54610e9f9190613eab565b905090565b61012f546000908015610eff5761012f6001820381548110610ec857610ec8613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16610f02565b60005b6fffffffffffffffffffffffffffffffff1691505090565b60006101325461013154610e9f9190613eab565b600080610f3a83611920565b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013d602090815260408083205461013c9092529091205491925090670de0b6b3a764000090610dc5611b1d565b610f8c6124ed565b6000610f978161255c565b610130544210610fd95761013254610faf9084613ec2565b6101315561013254610fc664e8d4a5100084613eab565b610fd09190613ec2565b61013a55611060565b60004261013054610fea9190613e98565b905060006101315482610ffd9190613eab565b6101325490915061100e8287613efd565b6110189190613ec2565b6101315561013a5460009061102d9084613eab565b610132549091508161104464e8d4a5100088613eab565b61104e9190613efd565b6110589190613ec2565b61013a555050505b426101338190556101325461107491613efd565b6101305560408051848152602081018490527f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55910160405180910390a1505050565b3373ffffffffffffffffffffffffffffffffffffffff831603611105576040517f2333d00d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526101396020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016861515908117909155815194855291840192909252908201527f42ef3a6445090af5f522bf393e8d432b01eb65949f6e2bca70984e3630b63777906060015b60405180910390a15050565b6111b0612627565b336111ba8161255c565b336111c481612694565b826000036111fe576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112093361177e565b90508084111561124d576040517f92665351000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b61126884611259610ea4565b6112639190613e98565b612709565b611285338561127633611920565b6112809190613e98565b612715565b60405184815233907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a26040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018590527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af115801561134d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113719190613f3f565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000276df8bfe424ab1aad1efc138eef3099a8ac8fe116300361143d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611244565b7f000000000000000000000000276df8bfe424ab1aad1efc138eef3099a8ac8fe173ffffffffffffffffffffffffffffffffffffffff166114b27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611244565b61155e81612745565b6040805160008082526020820190925261157a9183919061274d565b50565b6115863361294c565b565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000276df8bfe424ab1aad1efc138eef3099a8ac8fe116300361164d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611244565b7f000000000000000000000000276df8bfe424ab1aad1efc138eef3099a8ac8fe173ffffffffffffffffffffffffffffffffffffffff166116c27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611765576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611244565b61176e82612745565b61177a8282600161274d565b5050565b600061178982610df4565b61179283611920565b61179c9190613e98565b92915050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000276df8bfe424ab1aad1efc138eef3099a8ac8fe11614611869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401611244565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b61012e60205281600052604060002081815481106118ab57600080fd5b60009182526020909120015467ffffffffffffffff808216935068010000000000000000820416915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1683565b8061190781612956565b61177a826129c1565b6119186129dc565b611586612a5d565b73ffffffffffffffffffffffffffffffffffffffff8116600090815261012d6020526040812080548015610e6e57816001820381548110610e3757610e37613f10565b61196b6129dc565b6115866000612ae2565b606554339073ffffffffffffffffffffffffffffffffffffffff168114611a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e657200000000000000000000000000000000000000000000006064820152608401611244565b61157a81612ae2565b611a2f612b13565b61177a8282612b82565b611a416129dc565b62093a80811015611a83576040517fadc45a1700000000000000000000000000000000000000000000000000000000815262093a806004820152602401611244565b6301dfe200811115611ac7576040517fa39fe6440000000000000000000000000000000000000000000000000000000081526301dfe2006004820152602401611244565b6101358190556040518181527f3b897fd6944545fcb6a5d5b058781d763169157f8559ca1a7f3276b981d09971906020015b60405180910390a150565b6000610130544210611b1857506101305490565b504290565b600080611b28610ea4565b905080600003611b3b57505061013b5490565b8061013a5461013354611b4c611b04565b611b569190613e98565b611b609190613eab565b611b7290670de0b6b3a7640000613eab565b611b7c9190613ec2565b61013b54611b8a9190613efd565b91505090565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012d60205260408120610ded9083612ca4565b611bc86129dc565b7f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c4d576040517f1b81380300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff8573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611cd2576040517fe4ea100b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a18173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb611d5c60335473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044015b6020604051808303816000875af1158015611dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df39190613f3f565b505050565b611e006129dc565b611586612e56565b611e10612627565b33611e1a8161255c565b81600003611e54576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815261013860205260409020429055611e7d82611e73610ea4565b6112639190613efd565b611e953383611e8b33611920565b6112809190613efd565b60405182815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200160405180910390a26040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018390527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b73ffffffffffffffffffffffffffffffffffffffff16906323b872dd90606401611db0565b33611f5381612694565b61177a3383612b82565b61012f8181548110611f6e57600080fd5b60009182526020909120015467ffffffffffffffff8082169250680100000000000000008204169070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1683565b600054610100900460ff1615808015611fdf5750600054600160ff909116105b80611ff95750303b158015611ff9575060005460ff166001145b612085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401611244565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156120e357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff8216612130576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612138612ead565b612140612f4c565b612148612feb565b61215182612ae2565b62093a80610132556212750061013555801561177a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161119c565b816121ca81612956565b611df38383613082565b6121dc6129dc565b610130544211612218576040517f5691d11300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003612252576040517ffff9f93e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101328190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001611af9565b600080612293610ea4565b9050806000036122a65750506101345490565b8061013154610133546122b7611b04565b6122c19190613e98565b6122cb9190613eab565b6122dd90670de0b6b3a7640000613eab565b6122e79190613ec2565b61013454611b8a9190613efd565b61012d60205281600052604060002081815481106118ab57600080fd5b600061179c61012f83612ca4565b600061232b82610df4565b6040517f057a601b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301527f000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c56169063057a601b90602401602060405180830381865afa1580156123b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117929190613f5c565b806123e581612956565b61177a8261294c565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012e60205260408120610ded9083612ca4565b61157d6106763361177e565b61157a3382613082565b61243c6129dc565b6065805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915561249f60335473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b611586336129c1565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b176dad2916db0905cd2d65ed54fdc3a878affe41614611586576040517f4dd89e9400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612564612288565b61013455612570611b1d565b61013b5561257c611b04565b6101335573ffffffffffffffffffffffffffffffffffffffff81161561157a576125a581610d6f565b73ffffffffffffffffffffffffffffffffffffffff82166000908152610137602090815260408083209390935561013454610136909152919020556125e981610f2e565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261013d602090815260408083209390935561013b5461013c9091529190205550565b60975460ff1615611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611244565b6101355473ffffffffffffffffffffffffffffffffffffffff82166000908152610138602052604081205490916126ca91613efd565b90504281111561177a576040517f098aefdd00000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b61157a61012f826131c9565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012d6020526040902061177a90826131c9565b61157a6129dc565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561278057611df38361332a565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612805575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261280291810190613f5c565b60015b612891576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401611244565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612940576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401611244565b50611df3838383613434565b61157a8182613459565b73ffffffffffffffffffffffffffffffffffffffff811660009081526101396020908152604080832033845290915290205460ff1661157a576040517fc19f17a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6129ca8161294c565b61157a816129d783612320565b613082565b60335473ffffffffffffffffffffffffffffffffffffffff163314611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611244565b612a65612627565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ab83390565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b606580547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561157a816137e1565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c561614611586576040517f450d292900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b8a612627565b81612b948161255c565b81600003612bce576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612bd984610df4565b905080831115612c18576040517f9266535100000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b612c26848461127687611920565b612c438484612c3487610df4565b612c3e9190613e98565b613858565b612c4f83611259610ea4565b6040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018590527fbd0d30ac1729a6f57b09c27c8f39102f2704fbbf708747dcd198e45cf27f5282910160405180910390a150505050565b8154600090808203612cba57600091505061179c565b600080612cc8600184613e98565b905084868381548110612cdd57612cdd613f10565b60009182526020909120015467ffffffffffffffff161115612d05576000935050505061179c565b84868281548110612d1857612d18613f10565b60009182526020909120015467ffffffffffffffff1611612d8257858181548110612d4557612d45613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16935061179c92505050565b81811115612df95760006002612d988484613efd565b612da3906001613efd565b612dad9190613ec2565b905085878281548110612dc257612dc2613f10565b60009182526020909120015467ffffffffffffffff1611612de557809250612df3565b612df0600182613e98565b91505b50612d82565b808214612e0857612e08613f75565b858281548110612e1a57612e1a613f10565b60009182526020909120015470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff169695505050505050565b612e5e613888565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33612ab8565b600054610100900460ff16612f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b6115866138f4565b600054610100900460ff16612fe3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b611586613994565b600054610100900460ff16611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b61308a612627565b816130948161255c565b816000036130ce576040517fcbca5aa200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006130d984612320565b905080831115613118576040517f012801c000000000000000000000000000000000000000000000000000000000815260048101829052602401611244565b73ffffffffffffffffffffffffffffffffffffffff841660009081526101386020526040902042905561314f8484611e8b82611920565b613167848461315d87610df4565b612c3e9190613efd565b61317383611e73610ea4565b8373ffffffffffffffffffffffffffffffffffffffff167f945856e466506640ce955f1ec0de49513761175bad680d8503f7c8d45beabb20846040516131bb91815260200190565b60405180910390a250505050565b815460008115613203578360018303815481106131e8576131e8613f10565b60009182526020909120015467ffffffffffffffff16613206565b60005b67ffffffffffffffff1690504281146132d1576040805160608101825267ffffffffffffffff428116825243811660208084019182526fffffffffffffffffffffffffffffffff8089169585019586528954600181018b5560008b81529290922094519490910180549251955182167001000000000000000000000000000000000295841668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909316949093169390931717909116919091179055613324565b828460018403815481106132e7576132e7613f10565b600091825260209091200180546fffffffffffffffffffffffffffffffff9283167001000000000000000000000000000000000292169190911790555b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6133ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401611244565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61343d83613a55565b60008251118061344a5750805b15611df3576133248383613aa2565b613461612627565b8161346b8161255c565b73ffffffffffffffffffffffffffffffffffffffff831660009081526101376020526040902054801561367e5773ffffffffffffffffffffffffffffffffffffffff84166000818152610137602052604080822091909155517fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486906134f39084815260200190565b60405180910390a26040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c5681166004830152602482018390527f000000000000000000000000920cf626a271321c151d027030d5d08af699456b169063a9059cbb906044016020604051808303816000875af11580156135b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d49190613f3f565b506040517fb5ddb9c700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152602482018390527f000000000000000000000000b2a20fcdc506a685122847b21e34536359e94c56169063b5ddb9c790604401600060405180830381600087803b15801561366557600080fd5b505af1158015613679573d6000803e3d6000fd5b505050505b73ffffffffffffffffffffffffffffffffffffffff8416600090815261013d60205260408120546136b59064e8d4a5100090613ec2565b905080156113715773ffffffffffffffffffffffffffffffffffffffff8516600081815261013d602052604080822091909155517f816c86b1a5030bb39cbd10a56660a0fa4c5d0a682a45f2e865639083e61f439b906137189084815260200190565b60405180910390a26040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f0000000000000000000000000b2c639c533813f4aa9d7837caf62653d097ff85169063a9059cbb906044016020604051808303816000875af11580156137b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d99190613f3f565b505050505050565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815261012e6020526040902061177a90826131c9565b60975460ff16611586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611244565b600054610100900460ff1661398b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b61158633612ae2565b600054610100900460ff16613a2b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611244565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b613a5e8161332a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606073ffffffffffffffffffffffffffffffffffffffff83163b613b48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401611244565b6000808473ffffffffffffffffffffffffffffffffffffffff1684604051613b709190613fc8565b600060405180830381855af49150503d8060008114613bab576040519150601f19603f3d011682016040523d82523d6000602084013e613bb0565b606091505b5091509150613bd8828260405180606001604052806027815260200161403660279139613be1565b95945050505050565b60608315613bf0575081610ded565b610ded8383815115613c055781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112449190613fe4565b803573ffffffffffffffffffffffffffffffffffffffff81168114613c5d57600080fd5b919050565b600060208284031215613c7457600080fd5b610ded82613c39565b60008060408385031215613c9057600080fd5b613c9983613c39565b9150613ca760208401613c39565b90509250929050565b60008060408385031215613cc357600080fd5b50508035926020909101359150565b801515811461157a57600080fd5b60008060408385031215613cf357600080fd5b613cfc83613c39565b91506020830135613d0c81613cd2565b809150509250929050565b600060208284031215613d2957600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215613d7257600080fd5b613d7b83613c39565b9150602083013567ffffffffffffffff80821115613d9857600080fd5b818501915085601f830112613dac57600080fd5b813581811115613dbe57613dbe613d30565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613e0457613e04613d30565b81604052828152886020848701011115613e1d57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008060408385031215613e5257600080fd5b613e5b83613c39565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561179c5761179c613e69565b808202811582820484141761179c5761179c613e69565b600082613ef8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b8082018082111561179c5761179c613e69565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613f5157600080fd5b8151610ded81613cd2565b600060208284031215613f6e57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b60005b83811015613fbf578181015183820152602001613fa7565b50506000910152565b60008251613fda818460208701613fa4565b9190910192915050565b6020815260008251806020840152614003816040850160208701613fa4565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209cb43e413099481083a979f526e4d11b338687b52660aad553ea5b0b3f3a57bb64736f6c63430008130033
Net Worth in USD
Net Worth in ETH
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.