Source Code
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 75 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Unstake | 61018486 | 2 days ago | IN | 0 S | 0.00366305 | ||||
| Unstake | 61017064 | 2 days ago | IN | 0 S | 0.00280805 | ||||
| Cooldown | 60977799 | 2 days ago | IN | 0 S | 0.00934895 | ||||
| Cooldown | 60977328 | 2 days ago | IN | 0 S | 0.00828371 | ||||
| Cooldown | 60977315 | 2 days ago | IN | 0 S | 0.00850031 | ||||
| Cooldown | 60977122 | 2 days ago | IN | 0 S | 0.00911344 | ||||
| Unstake | 60976983 | 2 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60967751 | 3 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60919979 | 3 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60918869 | 3 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60910468 | 3 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60907355 | 3 days ago | IN | 0 S | 0.00425491 | ||||
| Unstake | 60907303 | 3 days ago | IN | 0 S | 0.00371002 | ||||
| Unstake | 60907277 | 3 days ago | IN | 0 S | 0.00209088 | ||||
| Unstake | 60907227 | 3 days ago | IN | 0 S | 0.00326738 | ||||
| Cooldown | 60851927 | 4 days ago | IN | 0 S | 0.00935033 | ||||
| Cooldown | 60693423 | 6 days ago | IN | 0 S | 0.00786766 | ||||
| Cooldown | 60613162 | 7 days ago | IN | 0 S | 0.00911135 | ||||
| Delegate | 60532868 | 9 days ago | IN | 0 S | 0.00242905 | ||||
| Cooldown | 60231444 | 13 days ago | IN | 0 S | 0.00911344 | ||||
| Cooldown | 60230912 | 13 days ago | IN | 0 S | 0.00911344 | ||||
| Stake | 60089682 | 15 days ago | IN | 0 S | 0.01048498 | ||||
| Cooldown | 60028538 | 16 days ago | IN | 0 S | 0.00637546 | ||||
| Cooldown | 60028500 | 16 days ago | IN | 0 S | 0.00786946 | ||||
| Delegate | 59995033 | 16 days ago | IN | 0 S | 0.0025505 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Staker
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 99999999 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "openzeppelin/access/Ownable.sol";
import {Ownable2Step} from "openzeppelin/access/Ownable2Step.sol";
import {Pausable} from "openzeppelin/utils/Pausable.sol";
import {ReentrancyGuard} from "openzeppelin/utils/ReentrancyGuard.sol";
import {SafeCast} from "openzeppelin/utils/math/SafeCast.sol";
import {ERC20} from "openzeppelin/token/ERC20/ERC20.sol";
import {ERC20Votes} from "openzeppelin/token/ERC20/extensions/ERC20Votes.sol";
import {EIP712} from "openzeppelin/utils/cryptography/EIP712.sol";
/// @title Staker contract
/// @notice Safety Module Staking contract, allowing users to stake assets & earn rewards.
/// The staked assets can be slashed as part of Trevee Safety Module. To unstake, users must first
/// execute a cooldown and wait for the required period.
contract Staker is ERC20Votes, Ownable2Step, Pausable, ReentrancyGuard {
using SafeERC20 for IERC20;
using SafeCast for *;
/** @notice Max BPS value : 100% */
uint256 private constant MAX_BPS = 10000;
/** @notice Unit value for calculations */
uint256 private constant UNIT = 1e18;
/** @notice Ratio (BPS) at which queued rewards will be distributed */
uint256 private constant UPDATE_REWARD_RATIO = 8500; // 85 %
/** @notice Initial exchange rate between assets and shares */
uint256 public constant INITIAL_EXCHANGE_RATE = 1e18;
/** @notice Duration (in seconds) of reward distributions */
uint256 public constant REWARD_DISTRIBUTION_DURATION = 2 weeks; // TODO : change this ?
/** @notice Maximum ratio (bps) of the total staked amound that can be slashed */
uint256 public constant MAX_SLASH_RATIO = 0.3 ether; // 30%
/** @notice Cooldown (in seconds) between 2 slashing events */
uint256 public constant SLASHING_COOLDOWN = 1 weeks;
/** @notice Period to wait before unstaking tokens */
uint256 public constant COOLDOWN_PERIOD = 2 weeks;
/** @notice Maximum amount of different rewards token to be used in distributions */
uint256 public constant MAX_REWARDS_LENGTH = 10;
/** @notice Maximum duration allowed for the freeze period */
uint256 private constant MAX_FREEZE_PERIOD_DURATION = 260 weeks; // 5 years
/** @notice Timestamp of the end of the freezing period */
uint256 public immutable freezePeriodEnd;
/** @notice ERC20 contract of the token that can be staked */
IERC20 public immutable baseToken;
/** @notice Address of the admin allowed to slash or return tokens */
address public slashingAdmin;
/** @notice Timestamp of the last slashing event */
uint256 public lastSlashingTimestamp;
/** @notice Current exchange rate between assets and shares */
uint256 public currentExchangeRate;
/**
* @notice UserRewardState struct
* lastRewardPerToken: last update reward per token value
* accruedRewards: total amount of rewards accrued
*/
struct UserRewardState {
uint256 lastRewardPerToken;
uint256 accruedRewards;
}
/**
* @notice RewardState struct
* rewardPerToken: current reward per token value
* lastUpdate: last state update timestamp
* distributionEndTimestamp: timestamp of the end of the current distribution
* ratePerSecond: current distribution rate per second
* currentRewardAmount: current amount of rewards in the distribution
* queuedRewardAmount: current amount of reward queued for the distribution
* userStates: users reward state for the reward token
*/
struct RewardState {
uint256 rewardPerToken;
uint128 lastUpdate;
uint128 distributionEndTimestamp;
uint256 ratePerSecond;
uint256 currentRewardAmount;
uint256 queuedRewardAmount;
// user address => user reward state
mapping(address => UserRewardState) userStates;
}
/**
* @notice UserClaimableRewards struct
* reward: address of the reward token
* claimableAmount: amount of rewards accrued by the user
*/
struct UserClaimableRewards {
address reward;
uint256 claimableAmount;
}
/**
* @notice UserClaimedRewards struct
* reward: address of the reward token
* amount: amount of rewards claimed by the user
*/
struct UserClaimedRewards {
address reward;
uint256 amount;
}
/**
* @notice CooldownState
* maturityTimestamp: timestamp when the cooldown period ends
* shares: amount of shares in cooldown
*/
struct CooldownState {
uint256 maturityTimestamp;
uint256 shares;
}
/** @notice List of reward token distributed by this contract (past & current) */
address[] public rewardTokens;
mapping(address => bool) public isAllowedRewardToken;
/** @notice Reward state for each reward token */
mapping(address => RewardState) public rewardStates;
/** @notice Address allowed to deposit reward tokens */
mapping(address => bool) public rewardDepositors;
/** @notice Current cooldown state for each user */
mapping(address => CooldownState) public cooldownStates;
/** @notice Total amount of shares currently in cooldown */
uint256 public totalCurrentCooldownAmount;
/** @notice Event emitted when staking */
event Staked(
address indexed caller,
address indexed receiver,
uint256 amount,
uint256 shares
);
/** @notice Event emitted when calling cooldown */
event Cooldown(address indexed owner, uint256 shares, uint256 maturityTimestamp);
/** @notice Event emitted when unstaking */
event Unstaked(
address indexed owner,
address indexed receiver,
uint256 shares,
uint256 amount
);
/** @notice Event emitted when rewards are claimed */
event ClaimedRewards(
address indexed reward,
address indexed user,
address indexed receiver,
uint256 amount
);
/** @notice Event emitted when a new reward is added */
event NewRewards(
address indexed rewardToken,
uint256 amount,
uint256 endTimestamp
);
/** @notice Event emitted when a new reward token is assed to the list */
event NewRewardTokenListed(address indexed rewardToken);
/** @notice Event emitted when a new reward depositor is added */
event AddedRewardDepositor(address indexed depositor);
/** @notice Event emitted when a reward depositor is removed */
event RemovedRewardDepositor(address indexed depositor);
/** @notice Event emitted when the slashing admin is updated */
event SlashingAdminUpdated(address indexed oldSlashingAdmin, address indexed newSlashingAdmin);
/** @notice Event emitted when a slashing occurs */
event Slashed(uint256 amount, uint256 newExchangeRate);
/** @notice Event emitted when slashed tokens are returned to this contract */
event TokensReturned(uint256 amount, uint256 newExchangeRate);
/** @notice Error raised if the caller is not allowed */
error NotAllowed();
/** @notice Error raised if the given parameter is invalid */
error InvalidParameter();
/** @notice Error raised if the given address is zero */
error AddressZero();
/** @notice Error raised if the given amount is null */
error NullAmount();
/** @notice Error raised if the amount of shares to output will be 0 */
error SharesOutputZero();
/** @notice Error raised if the amount of assets to output will be 0 */
error AssetsOutputZero();
/** @notice Eroor raised if the given freeze period duration exceeds the maximum */
error InvalidFreezePeriodDuration();
/** @notice Eroor raised if the freezing period is still active */
error FreezingPeriod();
/** @notice Error raised if the given address is already listed as reward depositor */
error AlreadyListedDepositor();
/** @notice Error raised if the given address is not listed as reward depositor */
error NotListedDepositor();
/** @notice Error raised if the given reward token is not listed */
error RewardTokenNotAllowed();
/** @notice Error raised if the given reward token is already listed */
error RewardTokenAlreadyListed();
/** @notice Error raised if the maximum number of reward tokens is exceeded */
error MaxRewardTokenListExceeded();
/** @notice Error raised if the given amount exceeds the current balance */
error AmountExceedsBalance();
/** @notice Error raised if the current cooldown period of the user is not over */
error CooldownPeriodNotOver();
/** @notice Error raised if the user does not currently have a cooldown initiated */
error NoCooldown();
/** @notice Error raised when trying to slash too early after the previous slashing event */
error SlashingCooldown();
/** @notice Error raised if the user tries to delegate to the address zero */
error NoDelegationForbidden();
/**
* @notice Check that the caller is allowed to deposit rewards
*/
modifier onlyRewardDepositors() {
if (!rewardDepositors[msg.sender]) revert NotAllowed();
_;
}
/**
* @notice Check that the caller is allowed to slash deposits or give back tokens
*/
modifier onlySlashingAdmin() {
if (msg.sender != slashingAdmin) revert NotAllowed();
_;
}
/**
* @notice Check that the freezing period is over
*/
modifier freezingPeriod() {
if (block.timestamp < freezePeriodEnd) revert FreezingPeriod();
_;
}
constructor(
address _baseToken,
address _slashingAdmin,
string memory _name,
string memory _symbol,
string memory _version,
uint256 _freezePeriod
) ERC20(_name, _symbol) Ownable(msg.sender) EIP712(_name, _version) {
if (_baseToken == address(0)) revert AddressZero();
if (_slashingAdmin == address(0)) revert AddressZero();
if (_freezePeriod > MAX_FREEZE_PERIOD_DURATION) revert InvalidFreezePeriodDuration();
baseToken = IERC20(_baseToken);
slashingAdmin = _slashingAdmin;
freezePeriodEnd = block.timestamp + _freezePeriod;
currentExchangeRate = INITIAL_EXCHANGE_RATE;
}
/**
* @notice Get the last update timestamp for a reward token
* @param reward Address of the reward token
* @return uint256 : Last update timestamp
*/
function lastRewardUpdateTimestamp(
address reward
) public view returns (uint256) {
uint256 rewardEndTimestamp = rewardStates[reward].distributionEndTimestamp;
// If the distribution is already over, return the timestamp of the end of distribution
// to prevent from accruing rewards that do not exist
return block.timestamp > rewardEndTimestamp ? rewardEndTimestamp : block.timestamp;
}
/**
* @notice Get the list of all reward tokens
* @return address[] : List of reward tokens
*/
function getRewardTokens() external view returns (address[] memory) {
return rewardTokens;
}
/**
* @notice Get the current reward state of an user for a given reward token
* @param reward Address of the reward token
* @param user Address of the user
* @return UserRewardState : User reward state
*/
function getUserRewardState(
address reward,
address user
) external view returns (UserRewardState memory) {
return rewardStates[reward].userStates[user];
}
/**
* @notice Get the current amount of rewards accrued by an user for a given reward token
* @param reward Address of the reward token
* @param user Address of the user
* @return uint256 : amount of rewards accrued
*/
function getUserAccruedRewards(
address reward,
address user
) external view returns (uint256) {
return
rewardStates[reward].userStates[user].accruedRewards +
_getUserEarnedRewards(reward, user, _getNewRewardPerToken(reward));
}
/**
* @notice Get all current claimable amount of rewards for all reward tokens for a given user
* @param user Address of the user
* @return UserClaimableRewards[] : Amounts of rewards claimable by reward token
*/
function getUserTotalClaimableRewards(
address user
) external view returns (UserClaimableRewards[] memory) {
address[] memory rewards = rewardTokens;
uint256 rewardsLength = rewards.length;
UserClaimableRewards[]
memory rewardAmounts = new UserClaimableRewards[](rewardsLength);
// For each listed reward
for (uint256 i; i < rewardsLength; ) {
// Add the reward token to the list
rewardAmounts[i].reward = rewards[i];
// And add the calculated claimable amount of the given reward
// Accrued rewards from previous stakes + accrued rewards from current stake
rewardAmounts[i].claimableAmount =
rewardStates[rewards[i]].userStates[user].accruedRewards +
_getUserEarnedRewards(
rewards[i],
user,
_getNewRewardPerToken(rewards[i])
);
unchecked {
++i;
}
}
return rewardAmounts;
}
/**
* @dev Convert an amount of assets to shares based on the current exchange rate
* @param amount Amount of assets to convert
* @return uint256 : Amount of shares
*/
function _convertAssetToShares(uint256 amount) internal view returns (uint256) {
return (amount * currentExchangeRate) / UNIT;
}
/**
* @dev Convert an amount of shares to assets based on the current exchange rate
* @param amount Amount of shares to convert
* @return uint256 : Amount of assets
*/
function _convertSharesToAsset(uint256 amount) internal view returns (uint256) {
return (amount * UNIT) / currentExchangeRate;
}
/**
* @notice Preview the amount of shares that would be minted for a given amount of assets staked
* @param amount Amount of assets to stake
* @return uint256 : Amount of shares
*/
function previewStake(uint256 amount) external view returns (uint256) {
return _convertAssetToShares(amount);
}
/**
* @notice Preview the amount of assets that would be unstaked for a given amount of shares burned
* @param amount Amount of shares to unstake
* @return uint256 : Amount of assets
*/
function previewUnstake(uint256 amount) external view returns (uint256) {
return _convertSharesToAsset(amount);
}
/**
* @notice Stake an amount of assets and mint shares to the receiver
* @param amount Amount of assets to stake
* @param receiver Address to receive the shares minted
* @return uint256 : Amount of shares minted
*/
function stake(uint256 amount, address receiver) external nonReentrant whenNotPaused returns(uint256) {
if (amount == 0) revert NullAmount();
if (receiver == address(0)) revert AddressZero();
// Transfer the tokens from the user to the contract
baseToken.safeTransferFrom(msg.sender, address(this), amount);
// Mint the staked tokens to the receiver
uint256 shares = _convertAssetToShares(amount);
if(shares == 0) revert SharesOutputZero();
// Will also update the reward states
_mint(receiver, shares);
emit Staked(msg.sender, receiver, amount, shares);
return amount;
}
/**
* @notice Unstake an amount of shares in cooldown and send back the assets to the receiver
* @dev The shares must be in cooldown before being unstaked
* @param receiver Address to receive the assets
* @return uint256 : Amount of assets unstaked
*/
function unstake(address receiver) external nonReentrant whenNotPaused freezingPeriod returns(uint256) {
if (receiver == address(0)) revert AddressZero();
CooldownState storage cooldownState = cooldownStates[msg.sender];
// Check if the caller has an active cooldown
if(cooldownState.shares == 0) revert NoCooldown();
// Check if the cooldown period is over
if (block.timestamp < cooldownState.maturityTimestamp) revert CooldownPeriodNotOver();
uint256 shares = cooldownState.shares;
uint256 amount = _convertSharesToAsset(shares);
if(amount == 0) revert AssetsOutputZero();
// Reset the cooldown state for the user
cooldownState.shares = 0;
totalCurrentCooldownAmount -= shares;
// Shares were already burned when cooldown was called
// Send back the tokens
baseToken.safeTransfer(receiver, amount);
emit Unstaked(msg.sender, receiver, shares, amount);
return amount;
}
/**
* @notice Initiate a cooldown for a given amount of shares. Overrides the last cooldown if not unstaked.
* @dev Cooldown also makes tokens non-transferable
* @param amount Amount of shares to put in cooldown
*/
function cooldown(uint256 amount) external nonReentrant whenNotPaused freezingPeriod {
// Get the current coolown state for the user
CooldownState storage cooldownState = cooldownStates[msg.sender];
uint256 prevShares = cooldownState.shares;
if(amount > balanceOf(msg.sender) + prevShares) revert AmountExceedsBalance();
// Burn the share tokens for the cooldown
// If a previous cooldown is here, only burn or mint to adjust
// between the balance and the amount in cooldown.
// Mint & Burn will also update the reward states
if(amount > prevShares) {
_burn(msg.sender, amount - prevShares);
} else {
_mint(msg.sender, prevShares - amount);
}
totalCurrentCooldownAmount = totalCurrentCooldownAmount + amount - prevShares;
// Set the cooldown state for the user
uint256 maturityTimestamp = block.timestamp + COOLDOWN_PERIOD;
cooldownState.maturityTimestamp = maturityTimestamp;
cooldownState.shares = amount;
emit Cooldown(msg.sender, amount, maturityTimestamp);
}
/**
* @dev Override of the _update function to update the reward states during transfers
*/
function _update(address from, address to, uint256 value) internal virtual whenNotPaused override {
if (from != address(0)) {
_updateAllUserRewardStates(from);
}
if (to != address(0)) {
_updateAllUserRewardStates(to);
// Force delegation
if(delegates(to) == address(0)) {
_delegate(to, to);
}
}
super._update(from, to, value);
}
/**
* @dev Override of the _delegate function to prevent delegation to the address zero
*/
function _delegate(address account, address delegatee) internal override {
if(delegatee == address(0)) revert NoDelegationForbidden();
super._delegate(account, delegatee);
}
/**
* @notice Claim the accrued rewards for a given reward token
* @param reward Address of the reward token
* @param receiver Address to receive the rewards
* @return uint256 : Amount of rewards claimed
*/
function claimRewards(
address reward,
address receiver
) external nonReentrant whenNotPaused returns (uint256) {
if (reward == address(0) || receiver == address(0)) revert AddressZero();
return _claimRewards(reward, msg.sender, receiver);
}
/**
* @notice Claim all accrued rewards for all reward tokens
* @param receiver Address to receive the rewards
* @return UserClaimedRewards[] : Amounts of reward claimed
*/
function claimAllRewards(
address receiver
)
external
nonReentrant
whenNotPaused
returns (UserClaimedRewards[] memory)
{
if (receiver == address(0)) revert AddressZero();
return _claimAllRewards(msg.sender, receiver);
}
/**
* @notice Update the reward state for a given reward token
* @param reward Address of the reward token
*/
function updateRewardState(
address reward
) external nonReentrant whenNotPaused {
if (reward == address(0)) revert AddressZero();
_updateRewardState(reward);
}
/**
* @notice Update the reward state for a given user and reward token
* @param reward Address of the reward token
* @param user Address of the user
*/
function updateUserRewardState(
address reward,
address user
) external nonReentrant whenNotPaused {
if (reward == address(0) || user == address(0)) revert AddressZero();
_updateUserRewardState(reward, user);
}
/**
* @notice Update the reward state for all reward tokens
*/
function updateAllRewardStates() external nonReentrant whenNotPaused {
address[] memory _rewards = rewardTokens;
uint256 length = _rewards.length;
// For all reward token in the list, update the reward state
for (uint256 i; i < length; ) {
_updateRewardState(_rewards[i]);
unchecked {
++i;
}
}
}
/**
* @notice Update all reward states for a given user
* @param user Address of the user
*/
function updateAllUserRewardStates(address user) external nonReentrant whenNotPaused {
if (user == address(0)) revert AddressZero();
address[] memory _rewards = rewardTokens;
uint256 length = _rewards.length;
// For all reward token in the list, update the reward state
for (uint256 i; i < length; ) {
_updateUserRewardState(_rewards[i], user);
unchecked {
++i;
}
}
}
/**
* @notice Add rewards to the distribution queue
* @dev Set the amount of reward in the queue & push it to distribution if reaching the ratio
* @param rewardToken Address of the reward token
* @param amount Amount to queue
* @return bool : success
*/
function queueRewards(
address rewardToken,
uint256 amount
) external nonReentrant whenNotPaused onlyRewardDepositors returns (bool) {
if (amount == 0) revert NullAmount();
if (!isAllowedRewardToken[rewardToken]) revert RewardTokenNotAllowed();
RewardState storage state = rewardStates[rewardToken];
IERC20(rewardToken).safeTransferFrom(
msg.sender,
address(this),
amount
);
// Update the reward token state before queueing new rewards
_updateRewardState(rewardToken);
// Get the total queued amount (previous queued amount + new amount)
uint256 totalQueued = amount + state.queuedRewardAmount;
// If there is no current distribution (previous is over or new reward token):
// Start the new distribution directly without queueing the rewards
if (block.timestamp >= state.distributionEndTimestamp) {
state.queuedRewardAmount = 0;
_updateRewardDistribution(rewardToken, state, totalQueued);
return true;
}
// Calculate the remaining duration for the current distribution
// and the ratio of queued rewards compared to total rewards (queued + remaining in current distribution)
// state.distributionEndTimestamp - block.timestamp => remaining time in the current distribution
uint256 currentRemainingAmount = state.ratePerSecond * (state.distributionEndTimestamp - block.timestamp);
uint256 queuedAmountRatio = (totalQueued * MAX_BPS) / (totalQueued + currentRemainingAmount);
// If 85% or more of the total rewards are queued, move them to distribution
if (queuedAmountRatio >= UPDATE_REWARD_RATIO) {
state.queuedRewardAmount = 0;
_updateRewardDistribution(rewardToken, state, totalQueued);
} else {
state.queuedRewardAmount = totalQueued;
}
return true;
}
/**
* @dev Update the distribution parameters for a given reward token
* @param rewardToken Address of the reward token
* @param state State of the reward token
* @param rewardAmount Total amount ot distribute
*/
function _updateRewardDistribution(
address rewardToken,
RewardState storage state,
uint256 rewardAmount
) internal {
// Calculate the remaining duration of the current distribution (if not already over)
// to calculate the amount fo rewards not yet distributed, and add them to the new amount to distribute
if (block.timestamp < state.distributionEndTimestamp) {
uint256 remainingRewards = state.ratePerSecond * (state.distributionEndTimestamp - block.timestamp);
rewardAmount += remainingRewards;
}
// Calculate the new rate per second
// & update the storage for the new distribution state
state.ratePerSecond = rewardAmount / REWARD_DISTRIBUTION_DURATION;
// Precision loss check : saving dust for future distributions
uint256 recalculatedRewardAmount = state.ratePerSecond * REWARD_DISTRIBUTION_DURATION;
if(recalculatedRewardAmount < rewardAmount) {
state.queuedRewardAmount += (rewardAmount - recalculatedRewardAmount);
}
state.currentRewardAmount = recalculatedRewardAmount;
state.lastUpdate = block.timestamp.toUint128();
uint256 distributionEnd = block.timestamp + REWARD_DISTRIBUTION_DURATION;
state.distributionEndTimestamp = distributionEnd.toUint128();
emit NewRewards(rewardToken, recalculatedRewardAmount, distributionEnd);
}
function updateRewardDistribution(
address rewardToken
) external nonReentrant whenNotPaused {
if (rewardToken == address(0)) revert AddressZero();
if (!isAllowedRewardToken[rewardToken]) revert RewardTokenNotAllowed();
RewardState storage state = rewardStates[rewardToken];
// Update the reward state for the given reward token
_updateRewardState(rewardToken);
uint256 totalQueued = state.queuedRewardAmount;
// Nothing to update and add to the distribution
if(totalQueued == 0) return;
if (block.timestamp >= state.distributionEndTimestamp) {
state.queuedRewardAmount = 0;
_updateRewardDistribution(rewardToken, state, totalQueued);
}
// Calculate the remaining duration for the current distribution
// and the ratio of queued rewards compared to total rewards (queued + remaining in current distribution)
// state.distributionEndTimestamp - block.timestamp => remaining time in the current distribution
uint256 currentRemainingAmount = state.ratePerSecond * (state.distributionEndTimestamp - block.timestamp);
uint256 queuedAmountRatio = (totalQueued * MAX_BPS) / (totalQueued + currentRemainingAmount);
// If 85% or more of the total rewards are queued, move them to distribution
if (queuedAmountRatio >= UPDATE_REWARD_RATIO) {
state.queuedRewardAmount = 0;
_updateRewardDistribution(rewardToken, state, totalQueued);
}
}
/**
* @dev Calculate the new rewardPerToken value for a reward token distribution
* @param reward Address of the reward token
* @return uint256 : new rewardPerToken value
*/
function _getNewRewardPerToken(
address reward
) internal view returns (uint256) {
RewardState storage state = rewardStates[reward];
// If no funds are deposited, we don't want to distribute rewards
// Also accounts for the total is cooldown not entitled to rewards
uint256 totalStakedAmount = totalSupply();
if (totalStakedAmount == 0) return state.rewardPerToken;
uint256 totalAccruedAmount;
// Get the last update timestamp
uint256 lastRewardTimestamp = lastRewardUpdateTimestamp(reward);
if (state.lastUpdate == lastRewardTimestamp) return state.rewardPerToken;
totalAccruedAmount = (lastRewardTimestamp - state.lastUpdate) * state.ratePerSecond;
// Calculate the increase since the last update
return state.rewardPerToken + ((totalAccruedAmount * UNIT) / totalStakedAmount);
}
/**
* @dev Calculate the amount of rewards accrued by an user since last update for a reward token
* @param reward Address of the reward token
* @param user Address of the user
* @return uint256 : Accrued rewards amount for the user
*/
function _getUserEarnedRewards(
address reward,
address user,
uint256 currentRewardPerToken
) internal view returns (uint256) {
UserRewardState storage userState = rewardStates[reward].userStates[user];
// Get the user staked balance minus the amount in cooldown
uint256 userStakedAmount = balanceOf(user);
if (userStakedAmount == 0) return 0;
// If the user has a previous deposit (scaled balance is not null), calculate the
// earned rewards based on the increase of the rewardPerToken value
return (userStakedAmount * (currentRewardPerToken - userState.lastRewardPerToken)) / UNIT;
}
/**
* @dev Update the reward token distribution state
* @param reward Address of the reward token
*/
function _updateRewardState(address reward) internal returns(uint256 newRewardPerToken) {
RewardState storage state = rewardStates[reward];
// Update the storage with the new reward state
newRewardPerToken = _getNewRewardPerToken(reward);
uint256 lastUpdateTimestamp = lastRewardUpdateTimestamp(reward);
if(newRewardPerToken == state.rewardPerToken && lastUpdateTimestamp > state.lastUpdate) {
// If a distribution is ongoing, but no assets are staked, nothing is distributed
// so we push back those rewards in the queue for the next distribution.
uint256 undistributed = (lastUpdateTimestamp - state.lastUpdate) * state.ratePerSecond;
state.queuedRewardAmount += undistributed;
}
state.rewardPerToken = newRewardPerToken;
state.lastUpdate = lastUpdateTimestamp.toUint128();
}
/**
* @dev Update the user reward state for a given reward token
* @param reward Address of the reward token
* @param user Address of the user
*/
function _updateUserRewardState(address reward, address user) internal {
// Update the reward token state before the user's state
uint256 currentRewardPerToken = _updateRewardState(reward);
UserRewardState storage userState = rewardStates[reward].userStates[
user
];
// Update the storage with the new reward state
userState.accruedRewards += _getUserEarnedRewards(
reward,
user,
currentRewardPerToken
);
userState.lastRewardPerToken = currentRewardPerToken;
}
/**
* @dev Update the reward state of the given user for all the reward tokens
* @param user Address of the user
*/
function _updateAllUserRewardStates(address user) internal {
address[] memory _rewards = rewardTokens;
uint256 length = _rewards.length;
// For all reward token in the list, update the user's reward state
for (uint256 i; i < length; ) {
_updateUserRewardState(_rewards[i], user);
unchecked { ++i; }
}
}
/**
* @dev Claims rewards of an user for a given reward token and sends them to the receiver address
* @param reward Address of reward token
* @param user Address of the user
* @param receiver Address to receive the rewards
* @return uint256 : claimed amount
*/
function _claimRewards(
address reward,
address user,
address receiver
) internal returns (uint256) {
// Update all user states to get all current claimable rewards
_updateUserRewardState(reward, user);
UserRewardState storage userState = rewardStates[reward].userStates[user];
// Fetch the amount of rewards accrued by the user
uint256 rewardAmount = userState.accruedRewards;
if (rewardAmount == 0) return 0;
// Reset user's accrued rewards
userState.accruedRewards = 0;
// If the user accrued rewards, send them to the given receiver
IERC20(reward).safeTransfer(receiver, rewardAmount);
emit ClaimedRewards(reward, user, receiver, rewardAmount);
return rewardAmount;
}
/**
* @dev Claims all rewards of an user and sends them to the receiver address
* @param user Address of the user
* @param receiver Address to receive the rewards
* @return UserClaimedRewards[] : list of claimed rewards
*/
function _claimAllRewards(
address user,
address receiver
) internal returns (UserClaimedRewards[] memory) {
address[] memory rewards = rewardTokens;
uint256 rewardsLength = rewards.length;
UserClaimedRewards[] memory rewardAmounts = new UserClaimedRewards[](rewardsLength);
// Update all user states to get all current claimable rewards
_updateAllUserRewardStates(user);
// For each reward token in the reward list
for (uint256 i; i < rewardsLength; ) {
UserRewardState storage userState = rewardStates[rewards[i]].userStates[user];
// Fetch the amount of rewards accrued by the user
uint256 rewardAmount = userState.accruedRewards;
// Track the claimed amount for the reward token
rewardAmounts[i].reward = rewards[i];
rewardAmounts[i].amount = rewardAmount;
// If the user accrued no rewards, skip
if (rewardAmount > 0) {
// Reset user's accrued rewards
userState.accruedRewards = 0;
// For each reward token, send the accrued rewards to the given receiver
IERC20(rewards[i]).safeTransfer(receiver, rewardAmount);
emit ClaimedRewards(
rewards[i],
user,
receiver,
rewardAmount
);
}
unchecked { ++i; }
}
return rewardAmounts;
}
/**
* @notice Slash part of the staked assets and send them to the receiver
* @dev Slashing will update the exchange rate to reflect the assets taken out
* @param amount Amount of assets to slash
* @param receiver Address to receive the slashed assets
* @return uint256 : slashed amount
*/
function slash(uint256 amount, address receiver) external nonReentrant onlySlashingAdmin returns(uint256) {
if (amount == 0) revert NullAmount();
if (receiver == address(0)) revert AddressZero();
if (block.timestamp < lastSlashingTimestamp + SLASHING_COOLDOWN) revert SlashingCooldown();
uint256 totalShares = totalSupply() + totalCurrentCooldownAmount;
uint256 underlyingBalance = _convertSharesToAsset(totalShares);
uint256 maxSlashAmount = (underlyingBalance * MAX_SLASH_RATIO) / UNIT;
if(amount > maxSlashAmount) amount = maxSlashAmount;
// update exchange rate
uint256 newUnderlyingBalance = underlyingBalance - amount;
uint256 newExchangeRate = (((totalShares * UNIT) + newUnderlyingBalance - 1) / newUnderlyingBalance);
currentExchangeRate = newExchangeRate;
lastSlashingTimestamp = block.timestamp;
baseToken.safeTransfer(receiver, amount);
emit Slashed(amount, newExchangeRate);
return amount;
}
/**
* @notice Return slashed tokens to the contract
* @dev This will update the exchange rate to reflect the assets sent in
* @param amount Amount of assets to return
*/
function returnTokens(uint256 amount) external nonReentrant onlySlashingAdmin {
if (amount == 0) revert NullAmount();
uint256 totalShares = totalSupply() + totalCurrentCooldownAmount;
uint256 underlyingBalance = _convertSharesToAsset(totalShares);
// update exchange rate
uint256 newUnderlyingBalance = underlyingBalance + amount;
uint256 newExchangeRate = (((totalShares * UNIT) + newUnderlyingBalance - 1) / newUnderlyingBalance);
currentExchangeRate = newExchangeRate;
baseToken.safeTransferFrom(msg.sender, address(this), amount);
emit TokensReturned(amount, newExchangeRate);
}
/**
* @notice Pause the contract
*/
function pause() external onlyOwner {
_pause();
}
/**
* @notice Unpause the contract
*/
function unpause() external onlyOwner {
_unpause();
}
/**
* @notice Add a new reward token to the list of allowed reward tokens
* @param rewardToken Address of the reward token
*/
function addRewardToken(address rewardToken) external onlyOwner {
if (rewardToken == address(0)) revert AddressZero();
if (isAllowedRewardToken[rewardToken]) revert RewardTokenAlreadyListed();
if (rewardTokens.length >= MAX_REWARDS_LENGTH) revert MaxRewardTokenListExceeded();
isAllowedRewardToken[rewardToken] = true;
rewardTokens.push(rewardToken);
emit NewRewardTokenListed(rewardToken);
}
/**
* @notice Add an address to the list of allowed reward depositors
* @param depositor Address to deposit rewards
*/
function addRewardDepositor(address depositor) external onlyOwner {
if (depositor == address(0)) revert AddressZero();
if (rewardDepositors[depositor]) revert AlreadyListedDepositor();
rewardDepositors[depositor] = true;
emit AddedRewardDepositor(depositor);
}
/**
* @notice Remove an address from the list of allowed reward depositors
* @param depositor Address to deposit rewards
*/
function removeRewardDepositor(address depositor) external onlyOwner {
if (depositor == address(0)) revert AddressZero();
if (!rewardDepositors[depositor]) revert NotListedDepositor();
rewardDepositors[depositor] = false;
emit RemovedRewardDepositor(depositor);
}
/**
* @notice Update the slashing admin address
* @param newSlashingAdmin Address of the new slashing admin
*/
function changeSlashingAdmin(address newSlashingAdmin) external onlyOwner {
if (newSlashingAdmin == address(0)) revert AddressZero();
address oldSlashingAdmin = slashingAdmin;
slashingAdmin = newSlashingAdmin;
emit SlashingAdminUpdated(oldSlashingAdmin, newSlashingAdmin);
}
/**
* @notice Rescue tokens from the contract, expect for the base token
* @param token Address of the token to rescue
* @param amount Amount of tokens to rescue
*/
function rescueTokens(address token, uint256 amount) external onlyOwner {
if (token == address(baseToken)) revert NotAllowed();
if (amount == 0) return;
IERC20(token).safeTransfer(msg.sender, amount);
}
function renounceOwnership() public override onlyOwner {
revert();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.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.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
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.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
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() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.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 Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_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 {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_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());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* 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 returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual 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 default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual 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 `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC20Votes.sol)
pragma solidity ^0.8.20;
import {ERC20} from "../ERC20.sol";
import {Votes} from "../../../governance/utils/Votes.sol";
import {Checkpoints} from "../../../utils/structs/Checkpoints.sol";
/**
* @dev Extension of ERC-20 to support Compound-like voting and delegation. This version is more generic than Compound's,
* and supports token supply up to 2^208^ - 1, while COMP is limited to 2^96^ - 1.
*
* NOTE: This contract does not provide interface compatibility with Compound's COMP token.
*
* This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either
* by calling the {Votes-delegate} function directly, or by providing a signature to be used with {Votes-delegateBySig}. Voting
* power can be queried through the public accessors {Votes-getVotes} and {Votes-getPastVotes}.
*
* By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it
* requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.
*/
abstract contract ERC20Votes is ERC20, Votes {
/**
* @dev Total supply cap has been exceeded, introducing a risk of votes overflowing.
*/
error ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap);
/**
* @dev Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1).
*
* This maximum is enforced in {_update}. It limits the total supply of the token, which is otherwise a uint256,
* so that checkpoints can be stored in the Trace208 structure used by {Votes}. Increasing this value will not
* remove the underlying limitation, and will cause {_update} to fail because of a math overflow in
* {Votes-_transferVotingUnits}. An override could be used to further restrict the total supply (to a lower value) if
* additional logic requires it. When resolving override conflicts on this function, the minimum should be
* returned.
*/
function _maxSupply() internal view virtual returns (uint256) {
return type(uint208).max;
}
/**
* @dev Move voting power when tokens are transferred.
*
* Emits a {IVotes-DelegateVotesChanged} event.
*/
function _update(address from, address to, uint256 value) internal virtual override {
super._update(from, to, value);
if (from == address(0)) {
uint256 supply = totalSupply();
uint256 cap = _maxSupply();
if (supply > cap) {
revert ERC20ExceededSafeSupply(supply, cap);
}
}
_transferVotingUnits(from, to, value);
}
/**
* @dev Returns the voting units of an `account`.
*
* WARNING: Overriding this function may compromise the internal vote accounting.
* `ERC20Votes` assumes tokens map to voting units 1:1 and this is not easy to change.
*/
function _getVotingUnits(address account) internal view virtual override returns (uint256) {
return balanceOf(account);
}
/**
* @dev Get number of checkpoints for `account`.
*/
function numCheckpoints(address account) public view virtual returns (uint32) {
return _numCheckpoints(account);
}
/**
* @dev Get the `pos`-th checkpoint for `account`.
*/
function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoints.Checkpoint208 memory) {
return _checkpoints(account, pos);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.
*
* The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
* encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
* does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
* produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {IERC-5267}.
*/
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: By default this function reads _name which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Name() internal view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: By default this function reads _version which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Version() internal view returns (string memory) {
return _version.toStringWithFallback(_versionFallback);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (governance/utils/Votes.sol)
pragma solidity ^0.8.20;
import {IERC5805} from "../../interfaces/IERC5805.sol";
import {Context} from "../../utils/Context.sol";
import {Nonces} from "../../utils/Nonces.sol";
import {EIP712} from "../../utils/cryptography/EIP712.sol";
import {Checkpoints} from "../../utils/structs/Checkpoints.sol";
import {SafeCast} from "../../utils/math/SafeCast.sol";
import {ECDSA} from "../../utils/cryptography/ECDSA.sol";
import {Time} from "../../utils/types/Time.sol";
/**
* @dev This is a base abstract contract that tracks voting units, which are a measure of voting power that can be
* transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of
* "representative" that will pool delegated voting units from different accounts and can then use it to vote in
* decisions. In fact, voting units _must_ be delegated in order to count as actual votes, and an account has to
* delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative.
*
* This contract is often combined with a token contract such that voting units correspond to token units. For an
* example, see {ERC721Votes}.
*
* The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed
* at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the
* cost of this history tracking optional.
*
* When using this module the derived contract must implement {_getVotingUnits} (for example, make it return
* {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the
* previous example, it would be included in {ERC721-_update}).
*/
abstract contract Votes is Context, EIP712, Nonces, IERC5805 {
using Checkpoints for Checkpoints.Trace208;
bytes32 private constant DELEGATION_TYPEHASH =
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
mapping(address account => address) private _delegatee;
mapping(address delegatee => Checkpoints.Trace208) private _delegateCheckpoints;
Checkpoints.Trace208 private _totalCheckpoints;
/**
* @dev The clock was incorrectly modified.
*/
error ERC6372InconsistentClock();
/**
* @dev Lookup to future votes is not available.
*/
error ERC5805FutureLookup(uint256 timepoint, uint48 clock);
/**
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based
* checkpoints (and voting), in which case {CLOCK_MODE} should be overridden as well to match.
*/
function clock() public view virtual returns (uint48) {
return Time.blockNumber();
}
/**
* @dev Machine-readable description of the clock as specified in ERC-6372.
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() public view virtual returns (string memory) {
// Check that the clock was not modified
if (clock() != Time.blockNumber()) {
revert ERC6372InconsistentClock();
}
return "mode=blocknumber&from=default";
}
/**
* @dev Validate that a timepoint is in the past, and return it as a uint48.
*/
function _validateTimepoint(uint256 timepoint) internal view returns (uint48) {
uint48 currentTimepoint = clock();
if (timepoint >= currentTimepoint) revert ERC5805FutureLookup(timepoint, currentTimepoint);
return SafeCast.toUint48(timepoint);
}
/**
* @dev Returns the current amount of votes that `account` has.
*/
function getVotes(address account) public view virtual returns (uint256) {
return _delegateCheckpoints[account].latest();
}
/**
* @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*
* Requirements:
*
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
*/
function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256) {
return _delegateCheckpoints[account].upperLookupRecent(_validateTimepoint(timepoint));
}
/**
* @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*
* NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
* Votes that have not been delegated are still part of total supply, even though they would not participate in a
* vote.
*
* Requirements:
*
* - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.
*/
function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256) {
return _totalCheckpoints.upperLookupRecent(_validateTimepoint(timepoint));
}
/**
* @dev Returns the current total supply of votes.
*/
function _getTotalSupply() internal view virtual returns (uint256) {
return _totalCheckpoints.latest();
}
/**
* @dev Returns the delegate that `account` has chosen.
*/
function delegates(address account) public view virtual returns (address) {
return _delegatee[account];
}
/**
* @dev Delegates votes from the sender to `delegatee`.
*/
function delegate(address delegatee) public virtual {
address account = _msgSender();
_delegate(account, delegatee);
}
/**
* @dev Delegates votes from signer to `delegatee`.
*/
function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
if (block.timestamp > expiry) {
revert VotesExpiredSignature(expiry);
}
address signer = ECDSA.recover(
_hashTypedDataV4(keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry))),
v,
r,
s
);
_useCheckedNonce(signer, nonce);
_delegate(signer, delegatee);
}
/**
* @dev Delegate all of `account`'s voting units to `delegatee`.
*
* Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
*/
function _delegate(address account, address delegatee) internal virtual {
address oldDelegate = delegates(account);
_delegatee[account] = delegatee;
emit DelegateChanged(account, oldDelegate, delegatee);
_moveDelegateVotes(oldDelegate, delegatee, _getVotingUnits(account));
}
/**
* @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to`
* should be zero. Total supply of voting units will be adjusted with mints and burns.
*/
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual {
if (from == address(0)) {
_push(_totalCheckpoints, _add, SafeCast.toUint208(amount));
}
if (to == address(0)) {
_push(_totalCheckpoints, _subtract, SafeCast.toUint208(amount));
}
_moveDelegateVotes(delegates(from), delegates(to), amount);
}
/**
* @dev Moves delegated votes from one delegate to another.
*/
function _moveDelegateVotes(address from, address to, uint256 amount) internal virtual {
if (from != to && amount > 0) {
if (from != address(0)) {
(uint256 oldValue, uint256 newValue) = _push(
_delegateCheckpoints[from],
_subtract,
SafeCast.toUint208(amount)
);
emit DelegateVotesChanged(from, oldValue, newValue);
}
if (to != address(0)) {
(uint256 oldValue, uint256 newValue) = _push(
_delegateCheckpoints[to],
_add,
SafeCast.toUint208(amount)
);
emit DelegateVotesChanged(to, oldValue, newValue);
}
}
}
/**
* @dev Get number of checkpoints for `account`.
*/
function _numCheckpoints(address account) internal view virtual returns (uint32) {
return SafeCast.toUint32(_delegateCheckpoints[account].length());
}
/**
* @dev Get the `pos`-th checkpoint for `account`.
*/
function _checkpoints(
address account,
uint32 pos
) internal view virtual returns (Checkpoints.Checkpoint208 memory) {
return _delegateCheckpoints[account].at(pos);
}
function _push(
Checkpoints.Trace208 storage store,
function(uint208, uint208) view returns (uint208) op,
uint208 delta
) private returns (uint208 oldValue, uint208 newValue) {
return store.push(clock(), op(store.latest(), delta));
}
function _add(uint208 a, uint208 b) private pure returns (uint208) {
return a + b;
}
function _subtract(uint208 a, uint208 b) private pure returns (uint208) {
return a - b;
}
/**
* @dev Must return the voting units held by an account.
*/
function _getVotingUnits(address) internal view virtual returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/Checkpoints.sol)
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
pragma solidity ^0.8.20;
import {Math} from "../math/Math.sol";
/**
* @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
* time, and later looking up past values by block number. See {Votes} as an example.
*
* To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
* checkpoint for the current transaction block using the {push} function.
*/
library Checkpoints {
/**
* @dev A value was attempted to be inserted on a past checkpoint.
*/
error CheckpointUnorderedInsertion();
struct Trace224 {
Checkpoint224[] _checkpoints;
}
struct Checkpoint224 {
uint32 _key;
uint224 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the
* library.
*/
function push(
Trace224 storage self,
uint32 key,
uint224 value
) internal returns (uint224 oldValue, uint224 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace224 storage self) internal view returns (uint224) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint224 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace224 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint224[] storage self,
uint32 key,
uint224 value
) private returns (uint224 oldValue, uint224 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint224 storage last = _unsafeAccess(self, pos - 1);
uint32 lastKey = last._key;
uint224 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint224({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint224({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint224[] storage self,
uint256 pos
) private pure returns (Checkpoint224 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace208 {
Checkpoint208[] _checkpoints;
}
struct Checkpoint208 {
uint48 _key;
uint208 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
* library.
*/
function push(
Trace208 storage self,
uint48 key,
uint208 value
) internal returns (uint208 oldValue, uint208 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace208 storage self) internal view returns (uint208) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint208 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace208 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint208[] storage self,
uint48 key,
uint208 value
) private returns (uint208 oldValue, uint208 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint208 storage last = _unsafeAccess(self, pos - 1);
uint48 lastKey = last._key;
uint208 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint208({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint208({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint208[] storage self,
uint256 pos
) private pure returns (Checkpoint208 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace160 {
Checkpoint160[] _checkpoints;
}
struct Checkpoint160 {
uint96 _key;
uint160 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the
* library.
*/
function push(
Trace160 storage self,
uint96 key,
uint160 value
) internal returns (uint160 oldValue, uint160 newValue) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace160 storage self) internal view returns (uint160) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint160 storage ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace160 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint160[] storage self,
uint96 key,
uint160 value
) private returns (uint160 oldValue, uint160 newValue) {
uint256 pos = self.length;
if (pos > 0) {
Checkpoint160 storage last = _unsafeAccess(self, pos - 1);
uint96 lastKey = last._key;
uint160 lastValue = last._value;
// Checkpoint keys must be non-decreasing.
if (lastKey > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (lastKey == key) {
last._value = value;
} else {
self.push(Checkpoint160({_key: key, _value: value}));
}
return (lastValue, value);
} else {
self.push(Checkpoint160({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint160[] storage self,
uint256 pos
) private pure returns (Checkpoint160 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
assembly ("memory-safe") {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
assembly ("memory-safe") {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
assembly ("memory-safe") {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using
* {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.20;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5805.sol)
pragma solidity ^0.8.20;
import {IVotes} from "../governance/utils/IVotes.sol";
import {IERC6372} from "./IERC6372.sol";
interface IERC5805 is IERC6372, IVotes {}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides tracking nonces for addresses. Nonces will only increment.
*/
abstract contract Nonces {
/**
* @dev The nonce used for an `account` is not the expected current nonce.
*/
error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address account => uint256) private _nonces;
/**
* @dev Returns the next unused nonce for an address.
*/
function nonces(address owner) public view virtual returns (uint256) {
return _nonces[owner];
}
/**
* @dev Consumes a nonce.
*
* Returns the current value and increments nonce.
*/
function _useNonce(address owner) internal virtual returns (uint256) {
// For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
// decremented or reset. This guarantees that the nonce never overflows.
unchecked {
// It is important to do x++ and not ++x here.
return _nonces[owner]++;
}
}
/**
* @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
*/
function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
uint256 current = _useNonce(owner);
if (nonce != current) {
revert InvalidAccountNonce(owner, current);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(
bytes32 hash,
bytes memory signature
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly ("memory-safe") {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/types/Time.sol)
pragma solidity ^0.8.20;
import {Math} from "../math/Math.sol";
import {SafeCast} from "../math/SafeCast.sol";
/**
* @dev This library provides helpers for manipulating time-related objects.
*
* It uses the following types:
* - `uint48` for timepoints
* - `uint32` for durations
*
* While the library doesn't provide specific types for timepoints and duration, it does provide:
* - a `Delay` type to represent duration that can be programmed to change value automatically at a given point
* - additional helper functions
*/
library Time {
using Time for *;
/**
* @dev Get the block timestamp as a Timepoint.
*/
function timestamp() internal view returns (uint48) {
return SafeCast.toUint48(block.timestamp);
}
/**
* @dev Get the block number as a Timepoint.
*/
function blockNumber() internal view returns (uint48) {
return SafeCast.toUint48(block.number);
}
// ==================================================== Delay =====================================================
/**
* @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the
* future. The "effect" timepoint describes when the transitions happens from the "old" value to the "new" value.
* This allows updating the delay applied to some operation while keeping some guarantees.
*
* In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for
* some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set
* the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should
* still apply for some time.
*
*
* The `Delay` type is 112 bits long, and packs the following:
*
* ```
* | [uint48]: effect date (timepoint)
* | | [uint32]: value before (duration)
* ↓ ↓ ↓ [uint32]: value after (duration)
* 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC
* ```
*
* NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently
* supported.
*/
type Delay is uint112;
/**
* @dev Wrap a duration into a Delay to add the one-step "update in the future" feature
*/
function toDelay(uint32 duration) internal pure returns (Delay) {
return Delay.wrap(duration);
}
/**
* @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled
* change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered.
*/
function _getFullAt(
Delay self,
uint48 timepoint
) private pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {
(valueBefore, valueAfter, effect) = self.unpack();
return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect);
}
/**
* @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the
* effect timepoint is 0, then the pending value should not be considered.
*/
function getFull(Delay self) internal view returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {
return _getFullAt(self, timestamp());
}
/**
* @dev Get the current value.
*/
function get(Delay self) internal view returns (uint32) {
(uint32 delay, , ) = self.getFull();
return delay;
}
/**
* @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to
* enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the
* new delay becomes effective.
*/
function withUpdate(
Delay self,
uint32 newValue,
uint32 minSetback
) internal view returns (Delay updatedDelay, uint48 effect) {
uint32 value = self.get();
uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0));
effect = timestamp() + setback;
return (pack(value, newValue, effect), effect);
}
/**
* @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).
*/
function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {
uint112 raw = Delay.unwrap(self);
valueAfter = uint32(raw);
valueBefore = uint32(raw >> 32);
effect = uint48(raw >> 64);
return (valueBefore, valueAfter, effect);
}
/**
* @dev pack the components into a Delay object.
*/
function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) {
return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(buffer, add(0x20, offset)))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (governance/utils/IVotes.sol)
pragma solidity ^0.8.20;
/**
* @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
*/
interface IVotes {
/**
* @dev The signature used has expired.
*/
error VotesExpiredSignature(uint256 expiry);
/**
* @dev Emitted when an account changes their delegate.
*/
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/**
* @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units.
*/
event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes);
/**
* @dev Returns the current amount of votes that `account` has.
*/
function getVotes(address account) external view returns (uint256);
/**
* @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*/
function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*
* NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
* Votes that have not been delegated are still part of total supply, even though they would not participate in a
* vote.
*/
function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the delegate that `account` has chosen.
*/
function delegates(address account) external view returns (address);
/**
* @dev Delegates votes from the sender to `delegatee`.
*/
function delegate(address delegatee) external;
/**
* @dev Delegates votes from signer to `delegatee`.
*/
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC6372.sol)
pragma solidity ^0.8.20;
interface IERC6372 {
/**
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
*/
function clock() external view returns (uint48);
/**
* @dev Description of the clock
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}{
"remappings": [
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"solmate/=lib/solmate/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@layerzerolabs/oft-evm/=lib/devtools/packages/oft-evm/",
"@layerzerolabs/oapp-evm/=lib/devtools/packages/oapp-evm/",
"@layerzerolabs/test-devtools-evm-foundry/=lib/devtools/packages/test-devtools-evm-foundry/",
"@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/protocol/",
"@layerzerolabs/lz-evm-messagelib-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/messagelib/",
"@layerzerolabs/lz-evm-oapp-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/oapp/",
"@layerzerolabs/lz-evm-v1-0.7/=lib/LayerZero-v1/",
"solidity-bytes-utils/=lib/solidity-bytes-utils/",
"LayerZero-v1/=lib/LayerZero-v1/contracts/",
"devtools/=lib/devtools/packages/toolbox-foundry/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"layerzero-v2/=lib/layerzero-v2/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solady/=lib/solady/src/"
],
"optimizer": {
"enabled": true,
"runs": 99999999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"address","name":"_slashingAdmin","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_version","type":"string"},{"internalType":"uint256","name":"_freezePeriod","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"AlreadyListedDepositor","type":"error"},{"inputs":[],"name":"AmountExceedsBalance","type":"error"},{"inputs":[],"name":"AssetsOutputZero","type":"error"},{"inputs":[],"name":"CheckpointUnorderedInsertion","type":"error"},{"inputs":[],"name":"CooldownPeriodNotOver","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"uint256","name":"increasedSupply","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"}],"name":"ERC20ExceededSafeSupply","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"uint256","name":"timepoint","type":"uint256"},{"internalType":"uint48","name":"clock","type":"uint48"}],"name":"ERC5805FutureLookup","type":"error"},{"inputs":[],"name":"ERC6372InconsistentClock","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FreezingPeriod","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidFreezePeriodDuration","type":"error"},{"inputs":[],"name":"InvalidParameter","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"MaxRewardTokenListExceeded","type":"error"},{"inputs":[],"name":"NoCooldown","type":"error"},{"inputs":[],"name":"NoDelegationForbidden","type":"error"},{"inputs":[],"name":"NotAllowed","type":"error"},{"inputs":[],"name":"NotListedDepositor","type":"error"},{"inputs":[],"name":"NullAmount","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RewardTokenAlreadyListed","type":"error"},{"inputs":[],"name":"RewardTokenNotAllowed","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SharesOutputZero","type":"error"},{"inputs":[],"name":"SlashingCooldown","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"VotesExpiredSignature","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositor","type":"address"}],"name":"AddedRewardDepositor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"reward","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimedRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maturityTimestamp","type":"uint256"}],"name":"Cooldown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousVotes","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVotes","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"}],"name":"NewRewardTokenListed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTimestamp","type":"uint256"}],"name":"NewRewards","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":true,"internalType":"address","name":"depositor","type":"address"}],"name":"RemovedRewardDepositor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExchangeRate","type":"uint256"}],"name":"Slashed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldSlashingAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newSlashingAdmin","type":"address"}],"name":"SlashingAdminUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExchangeRate","type":"uint256"}],"name":"TokensReturned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstaked","type":"event"},{"inputs":[],"name":"CLOCK_MODE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COOLDOWN_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INITIAL_EXCHANGE_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_REWARDS_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SLASH_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_DISTRIBUTION_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLASHING_COOLDOWN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"}],"name":"addRewardDepositor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"}],"name":"addRewardToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newSlashingAdmin","type":"address"}],"name":"changeSlashingAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"pos","type":"uint32"}],"name":"checkpoints","outputs":[{"components":[{"internalType":"uint48","name":"_key","type":"uint48"},{"internalType":"uint208","name":"_value","type":"uint208"}],"internalType":"struct Checkpoints.Checkpoint208","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"claimAllRewards","outputs":[{"components":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Staker.UserClaimedRewards[]","name":"","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"address","name":"receiver","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clock","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"cooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cooldownStates","outputs":[{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentExchangeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezePeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"timepoint","type":"uint256"}],"name":"getPastTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"timepoint","type":"uint256"}],"name":"getPastVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserAccruedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserRewardState","outputs":[{"components":[{"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"internalType":"uint256","name":"accruedRewards","type":"uint256"}],"internalType":"struct Staker.UserRewardState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserTotalClaimableRewards","outputs":[{"components":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"uint256","name":"claimableAmount","type":"uint256"}],"internalType":"struct Staker.UserClaimableRewards[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isAllowedRewardToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"}],"name":"lastRewardUpdateTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastSlashingTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"previewStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"previewUnstake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"queueRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"}],"name":"removeRewardDepositor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"returnTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardDepositors","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardStates","outputs":[{"internalType":"uint256","name":"rewardPerToken","type":"uint256"},{"internalType":"uint128","name":"lastUpdate","type":"uint128"},{"internalType":"uint128","name":"distributionEndTimestamp","type":"uint128"},{"internalType":"uint256","name":"ratePerSecond","type":"uint256"},{"internalType":"uint256","name":"currentRewardAmount","type":"uint256"},{"internalType":"uint256","name":"queuedRewardAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"slash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slashingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"stake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalCurrentCooldownAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"unstake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateAllRewardStates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"updateAllUserRewardStates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"}],"name":"updateRewardDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"}],"name":"updateRewardState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"updateUserRewardState","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101a0806040523461057657615f86803803809161001d828561057a565b8339810160c082820312610576576100348261059d565b916100416020820161059d565b60408201519091906001600160401b03811161057657836100639183016105b1565b60608201516001600160401b03811161057657846100829184016105b1565b60808301519094906001600160401b0381116105765760a0916100a69185016105b1565b92015181519094906001600160401b03811161048657600354600181811c9116801561056c575b602082101461046857601f8111610509575b50806020601f82116001146104a5575f9161049a575b508160011b915f199060031b1c1916176003555b8051906001600160401b0382116104865760045490600182811c9216801561047c575b60208310146104685781601f8493116103fa575b50602090601f8311600114610394575f92610389575b50508160011b915f199060031b1c1916176004555b61017481610606565b610120526101818261078d565b6101405260208151910120908160e0526020815191012080610100524660a0526040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a081526101f260c08261057a565b5190206080523060c052331561037657600c54600b8054336001600160a01b031982168117909255604051959291906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a36001600160a81b031916600c556001600d556001600160a01b0316908115610367576001600160a01b03169081156103675763095f6a008311610358576101805260018060a01b0319600e541617600e5542018042116103445761016052670de0b6b3a76400006010556156c090816108c6823960805181614d87015260a05181614e44015260c05181614d58015260e05181614dd601526101005181614dfc01526101205181611d4901526101405181611d72015261016051818181612a8801528181612aef0152613170015261018051818181610f2c0152818161115801528181611a1301528181612a2f01526137c90152f35b634e487b7160e01b5f52601160045260245ffd5b63776f8e5760e01b5f5260045ffd5b639fabe1c160e01b5f5260045ffd5b631e4fbdf760e01b5f525f60045260245ffd5b015190505f80610156565b60045f9081528281209350601f198516905b8181106103e257509084600195949392106103ca575b505050811b0160045561016b565b01515f1960f88460031b161c191690555f80806103bc565b929360206001819287860151815501950193016103a6565b60045f529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c8101916020851061045e575b90601f859493920160051c01905b8181106104505750610140565b5f8155849350600101610443565b9091508190610435565b634e487b7160e01b5f52602260045260245ffd5b91607f169161012c565b634e487b7160e01b5f52604160045260245ffd5b90508301515f6100f5565b60035f9081528181209250601f198416905b8181106104f1575090836001949392106104d9575b5050811b01600355610109565b8501515f1960f88460031b161c191690555f806104cc565b9192602060018192868a0151815501940192016104b7565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c81019160208410610562575b601f0160051c01905b81811061055757506100df565b5f815560010161054a565b9091508190610541565b90607f16906100cd565b5f80fd5b601f909101601f19168101906001600160401b0382119082101761048657604052565b51906001600160a01b038216820361057657565b81601f82011215610576578051906001600160401b03821161048657604051926105e5601f8401601f19166020018561057a565b8284526020838301011161057657815f9260208093018386015e8301015290565b908151602081105f14610680575090601f815111610640576020815191015160208210610631571790565b5f198260200360031b1b161790565b604460209160405192839163305a27a960e01b83528160048401528051918291826024860152018484015e5f828201840152601f01601f19168101030190fd5b6001600160401b03811161048657600554600181811c91168015610783575b602082101461046857601f8111610750575b50602092601f82116001146106ef57928192935f926106e4575b50508160011b915f199060031b1c19161760055560ff90565b015190505f806106cb565b601f1982169360055f52805f20915f5b8681106107385750836001959610610720575b505050811b0160055560ff90565b01515f1960f88460031b161c191690555f8080610712565b919260206001819286850151815501940192016106ff565b60055f52601f60205f20910160051c810190601f830160051c015b81811061077857506106b1565b5f815560010161076b565b90607f169061069f565b908151602081105f146107b8575090601f815111610640576020815191015160208210610631571790565b6001600160401b03811161048657600654600181811c911680156108bb575b602082101461046857601f8111610888575b50602092601f821160011461082757928192935f9261081c575b50508160011b915f199060031b1c19161760065560ff90565b015190505f80610803565b601f1982169360065f52805f20915f5b8681106108705750836001959610610858575b505050811b0160065560ff90565b01515f1960f88460031b161c191690555f808061084a565b91926020600181928685015181550194019201610837565b60065f52601f60205f20910160051c810190601f830160051c015b8181106108b057506107e9565b5f81556001016108a3565b90607f16906107d756fe60806040526004361015610011575f80fd5b5f3560e01c806305528f4e1461047f57806306fdde031461047a578063095ea7b3146104755780630b670b1a14610470578063156ce5f81461046b57806318160ddd146104665780631c03e6cc14610461578063228fe6171461045c57806323b872dd14610457578063313ce5671461045257806332dac32d1461044d5780633a46b1a8146104485780633ae1786f146104435780633c7176cf1461043e5780633d82e3c1146104395780633f4ba83a146104345780634bf5d7e91461042f578063573761981461042a57806358146d1714610425578063587cde1e146104205780635af06ea71461041b5780635c19a95c146104165780635c745a3d146104115780635c975abb1461040c5780635e580f5f146104075780636e99d52f146103715780636fcfff451461040257806370a08231146103fd578063715018a6146103f8578063727a5d57146103f35780637935f721146103ee57806379ba5097146103e95780637acb7757146103e45780637bb7bed1146103df5780637ecebe00146103da57806383ea2532146103d55780638456cb59146103d057806384b0196e146103cb5780638b1154f0146103c65780638da5cb5b146103c15780638e539e8c146103bc57806391767552146103b757806391ddadf4146103b2578063955bdea1146103ad57806395d89b41146103a8578063968565fc146103a35780639964c09f1461039e5780639ab24eb0146103995780639bca43c0146103945780639caed1d61461038f578063a36849771461038a578063a9059cbb14610385578063ab576cb514610380578063b022418c1461037b578063b287ff8214610376578063c094b1c714610371578063c3cda5201461036c578063c4f59f9b14610367578063c519a7bf14610362578063c55dae631461035d578063cca3ae7214610358578063da27604014610353578063dd62ed3e1461034e578063e30c397814610349578063e7e5af2914610344578063e991560f1461033f578063f1127ed81461033a578063f1e42ccd14610335578063f2888dbb14610330578063f2fde38b1461032b5763f3805cc014610326575f80fd5b613371565b6132b3565b613127565b61307c565b612f88565b612df1565b612d3c565b612ceb565b612c5a565b612aab565b612a53565b6129e5565b612994565b612904565b6127c0565b611608565b612780565b6126cf565b612694565b612645565b61260a565b612596565b6124e5565b61245f565b6123c6565b61238b565b6122c8565b61223d565b6121f4565b6121b8565b6120db565b61208a565b611ecb565b611d13565b611c6a565b611bee565b611b8b565b611b07565b61199d565b611893565b6117d1565b61177f565b611749565b6116e9565b611643565b6115b2565b61156f565b611526565b6114e6565b61146c565b6113f3565b6113b3565b611368565b6112a1565b6111e3565b611024565b610fbc565b610e53565b610d31565b610cf6565b610cbd565b610ba1565b610aac565b61095a565b61091f565b6108e6565b61087e565b61075a565b610644565b6104ce565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036104a757565b5f80fd5b6024359073ffffffffffffffffffffffffffffffffffffffff821682036104a757565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61051a610484565b610522613b46565b1680156105c557805f52601460205260ff60405f20541661059d57805f52601460205261057760405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055565b7f50f7e50b19f1e2e9d15f76be42d5d0eea98162fa39d0c1112c87c1a3e94f80665f80a2005b7f91d703dd000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9fabe1c1000000000000000000000000000000000000000000000000000000005f5260045ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b9060206106419281815201906105ed565b90565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576040515f60035461068281613435565b808452906001811690811561071857506001146106ba575b6106b6836106aa81850382613574565b60405191829182610630565b0390f35b60035f9081527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b939250905b8082106106fe575090915081016020016106aa61069a565b9192600181602092548385880101520191019092916106e6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208086019190915291151560051b840190910191506106aa905061069a565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610791610484565b60243533156108525773ffffffffffffffffffffffffffffffffffffffff8216918215610826576107ec8291335f52600160205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5560405190815233907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3602060405160018152f35b7f94280d62000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7fe602df05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6108ca610484565b165f526012602052602060ff60405f2054166040519015158152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051600a8152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020600254604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610991610484565b610999613b46565b73ffffffffffffffffffffffffffffffffffffffff81169081156105c5575f8281526012602052604090205460ff16610a8457600a6011541015610a5c5780610a31610a06610a369373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055565b6135b5565b7f94818bcde148f9bd2db48b76249e6439b53c8b7258295eedf1d1008aa66c74ea5f80a2005b7fb0de2a7e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fa51fe5ed000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff610af8610484565b610b00613b46565b1680156105c557805f52601460205260ff60405f20541615610b7957805f526014602052610b5360405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008154169055565b7f7d180af120a8dcd38d344c3bc08e175faf5d1de10457c89bcf45eb5f4514883d5f80a2005b7f017eafa7000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610bd8610484565b610be06104ab565b6044359073ffffffffffffffffffffffffffffffffffffffff83165f526001602052610c2d3360405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8410610c6d575b610c619350613b67565b60405160018152602090f35b828410610c8957610c8483610c6195033383614914565b610c57565b82847ffb8f41b2000000000000000000000000000000000000000000000000000000005f523360045260245260445260645ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405160128152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020601654604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610d68610484565b73ffffffffffffffffffffffffffffffffffffffff60243591165f526009602052610d9660405f2091613d58565b8154905f829160058411610dfb575b610db0935084614b3f565b9081610de057505060205f5b79ffffffffffffffffffffffffffffffffffffffffffffffffffff60405191168152f35b610deb602092613719565b905f52815f20015460301c610dbc565b9192610e06816149ca565b8103908111610e4e57610db093855f5265ffffffffffff8260205f2001541665ffffffffffff8516105f14610e3c575091610da5565b929150610e4890613671565b90610da5565b613624565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757600435610e8d613daa565b73ffffffffffffffffffffffffffffffffffffffff600e54163303610f94578015610f6c57600254906016548201809211610e4e57610ecb82613de3565b91818301809311610e4e5782610f15610f107f8eac21849f07f4ad3ad263a83dafa0f2d3427034f0233fca7f93a10e43d602d095610f0b610f1a9561368c565b61367f565b613719565b613753565b90610f2482601055565b610f508130337f0000000000000000000000000000000000000000000000000000000000000000613e10565b604080519182526020820192909252a1610f6a6001600d55565b005b7fe5a74490000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f3d693ada000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611008610484565b165f526014602052602060ff60405f2054166040519015158152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75760043561105e6104ab565b611066613daa565b73ffffffffffffffffffffffffffffffffffffffff600e54163303610f945781908215610f6c5773ffffffffffffffffffffffffffffffffffffffff8116156105c5576110b4600f54613651565b42106111bb576106b6926110cd6002546016549061367f565b906110d782613de3565b906110f26110e4836136b0565b670de0b6b3a7640000900490565b8091116111b1575b509161117c84611143610f0b610f15610f106111949761113b867f4f5f38ee30b01a960b4dfdcd520a3ca59c1a664a32dcfe5418ca79b0de6b72369b613746565b93849161368c565b9261114d84601055565b61115642600f55565b7f0000000000000000000000000000000000000000000000000000000000000000613e7c565b60408051858152602081019290925290918291820190565b0390a16111a16001600d55565b6040519081529081906020820190565b935061117c6110fa565b7f61beb0bb000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611219613b46565b600c5460ff8160a01c1615611279577fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600c557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576112d843614982565b65ffffffffffff806112e943614982565b16911603611340576106b6604051611302604082613574565b601d81527f6d6f64653d626c6f636b6e756d6265722666726f6d3d64656661756c7400000060208201526040519182916020835260208301906105ed565b7f6ff07140000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610f6a6113a2610484565b602435906113ae613b46565b61379b565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051670de0b6b3a76400008152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61143f610484565b165f526008602052602073ffffffffffffffffffffffffffffffffffffffff60405f205416604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576114a3610484565b6024356114ae613daa565b6114b6613ed9565b335f52601460205260ff60405f20541615610f94576114d491613804565b6001600d556040519015158152602090f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610f6a611520610484565b33614182565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567611562610484565b61396d565b604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060ff600c5460a01c166040519015158152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576116016115ec610484565b6115f4613daa565b6115fc613ed9565b6139a6565b6001600d55005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051621275008152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61168f610484565b165f52600960205260405f205463ffffffff81116116b95760405163ffffffff9091168152602090f35b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52602060045260245260445ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567611725610484565b73ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f205490565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576104a7613b46565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020670de0b6b3a76400006117c860043560105490613706565b04604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61181d610484565b611825613b46565b1680156105c55773ffffffffffffffffffffffffffffffffffffffff600e54827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600e55167f5941313b333454ac6c9554eecf88be0f00f3da0e321b673ee0614b916df2d75b5f80a3005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7573373ffffffffffffffffffffffffffffffffffffffff600c541603611971577fffffffffffffffffffffffff0000000000000000000000000000000000000000600c5416600c55600b54337fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600b5573ffffffffffffffffffffffffffffffffffffffff3391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576004356119d76104ab565b906119e0613daa565b6119e8613ed9565b8015610f6c5773ffffffffffffffffffffffffffffffffffffffff821680156105c557611a378230337f0000000000000000000000000000000000000000000000000000000000000000613e10565b611a4082614277565b8015611a9857611a53816106b695614291565b60408051848152602081019290925233917f6c86f3fd5118b3aa8bb4f389a617046de0a3d3d477de1a1673d227f802f616dc91819081015b0390a36111a16001600d55565b7f7d5c26d4000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b8054821015611b02575f5260205f2001905f90565b611ac0565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576004356011548110156104a75773ffffffffffffffffffffffffffffffffffffffff60209160115f527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68015416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611bd7610484565b165f526007602052602060405f2054604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611c3a610484565b165f52601560205260405f2060018154910154906106b66040519283928360209093929193604081019481520152565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611ca0613b46565b611ca8613ed9565b740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff600c541617600c557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611e0f611d6d7f0000000000000000000000000000000000000000000000000000000000000000614c91565b611d967f0000000000000000000000000000000000000000000000000000000000000000614d0a565b6020604051611da58282613574565b5f815281611e1d818301947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe083013687376040519788977f0f00000000000000000000000000000000000000000000000000000000000000895260e0858a015260e08901906105ed565b9087820360408901526105ed565b914660608701523060808701525f60a087015285830360c087015251918281520192915f5b828110611e5157505050500390f35b835185528695509381019392810192600101611e42565b60206040818301928281528451809452019201905f5b818110611e8b5750505090565b9091926020604082611ec060019488516020809173ffffffffffffffffffffffffffffffffffffffff81511684520151910152565b019401929101611e7e565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611f02610484565b611f0a613abc565b90815190611f1782613aa4565b92611f256040519485613574565b8284527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611f5284613aa4565b015f5b8181106120735750505f5b838110611f7557604051806106b68782611e68565b80611fc8611fa2611f8860019486613b32565b5173ffffffffffffffffffffffffffffffffffffffff1690565b611fac8389613b32565b519073ffffffffffffffffffffffffffffffffffffffff169052565b61205e8261202a866005612006611fe2611f88888b613b32565b73ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b015461205861203c611f888588613b32565b8761205261204d611f88888b613b32565b6143ca565b9161445e565b9061367f565b602061206a8389613b32565b51015201611f60565b60209061207e613b1a565b82828901015201611f55565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600b5416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612115600435613d58565b600a54905f829160058411612164575b6121319350600a614b3f565b8061214257506040515f8152602090f35b61215f612150602092613719565b600a5f52825f20015460301c90565b610dbc565b919261216f816149ca565b8103908111610e4e5761213193600a5f5265ffffffffffff8260205f2001541665ffffffffffff8516105f146121a6575091612125565b9291506121b290613671565b90612125565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567600435613de3565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602061222d43614982565b65ffffffffffff60405191168152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612273613daa565b61227b613ed9565b612283613abc565b80515f5b818110612295576001600d55005b806122c173ffffffffffffffffffffffffffffffffffffffff6122ba60019487613b32565b5116613f10565b5001612287565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576040515f60045461230681613435565b8084529060018116908115610718575060011461232d576106b6836106aa81850382613574565b60045f9081527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b939250905b808210612371575090915081016020016106aa61069a565b919260018160209254838588010152019101909291612359565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020600f54604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576123fd610484565b6124056104ab565b61240d613daa565b612415613ed9565b73ffffffffffffffffffffffffffffffffffffffff8216158015612441575b6105c557611601916144f6565b5073ffffffffffffffffffffffffffffffffffffffff811615612434565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6124ab610484565b165f526009602052602079ffffffffffffffffffffffffffffffffffffffffffffffffffff6124dc60405f2061456a565b16604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761251c610484565b612524613daa565b61252c613ed9565b73ffffffffffffffffffffffffffffffffffffffff8116156105c557612550613abc565b8051905f5b828110612563576001600d55005b806125908573ffffffffffffffffffffffffffffffffffffffff61258960019587613b32565b51166144f6565b01612555565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576125cd610484565b6125d5613daa565b6125dd613ed9565b73ffffffffffffffffffffffffffffffffffffffff8116156105c55761260290613f10565b506001600d55005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020601054604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761268961267f610484565b6024359033613b67565b602060405160018152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405162093a808152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612706610484565b61276c6127116104ab565b9173ffffffffffffffffffffffffffffffffffffffff81165f526013602052600161276084600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b015492612052826143ca565b8101809111610e4e57602090604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051670429d069189e00008152f35b346104a75760c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576127f7610484565b6044359060243560643560ff811681036104a75760843560a435918542116128d857916128cc916128d3936042610f6a9860405160208101917fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf835273ffffffffffffffffffffffffffffffffffffffff8b16604083015289606083015260808201526080815261288960a082613574565b519020612894614d41565b90604051917f1901000000000000000000000000000000000000000000000000000000000000835260028301526022820152206145d1565b91826145e9565b614182565b857f4683af0e000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761293a613abc565b6040518091602082016020835281518091526020604084019201905f5b818110612965575050500390f35b825173ffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101612957565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600e5416604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757600435612ae5613daa565b612aed613ed9565b7f00000000000000000000000000000000000000000000000000000000000000004210612c3257335f52601560205260405f2060018101805491612b5883612b523373ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5461367f565b8411612c0a5783612be592612bbd612bb8867fa345023a4eda421d4dbe108023f197e12ac173da60a22f9c5a82765eff7f4bf99785115f14612bf257612ba7612ba18287613746565b3361464d565b612bb38560165461367f565b613746565b601655565b612bc642613661565b8093555560405191829133958360209093929193604081019481520152565b0390a2610f6a6001600d55565b612c05612bff8683613746565b33614291565b612ba7565b7f96ab19c8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fba8d8234000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020612ce2612c96610484565b73ffffffffffffffffffffffffffffffffffffffff612cb36104ab565b91165f526001835260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600c5416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff612d88610484565b165f5260136020526fffffffffffffffffffffffffffffffff60405f208054600182015491600281015490600460038201549101549160405195869560c087019587528180821616602088015260801c1660408601526060850152608084015260a08301520390f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612e28610484565b612e30613daa565b612e38613ed9565b73ffffffffffffffffffffffffffffffffffffffff811680156105c557612e5d613abc565b90815191612e6a836147e4565b93612e7433614ff7565b5f5b848110612e97576106b686612e8b6001600d55565b60405191829182611e68565b6001908482612eb2336005612006611fe2611f88888c613b32565b01805490612ed0612ec6611f88868a613b32565b611fac868d613b32565b816020612edd868d613b32565b51015281612eef575b50505001612e76565b5f9055612f258186612f20612f07611f88888c613b32565b73ffffffffffffffffffffffffffffffffffffffff1690565b613e7c565b73ffffffffffffffffffffffffffffffffffffffff612f47611f888589613b32565b167ffad55f843dbd67b821d107dd22535d77fb9384daa21dc35a976588f81997b7b360405180612f7d3395829190602083019252565b0390a4845f80612ee6565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612fbf610484565b6024359063ffffffff821682036104a7576106b69173ffffffffffffffffffffffffffffffffffffffff61301992612ff5613b1a565b50612ffe613b1a565b50165f52600960205260405f20613013613b1a565b50611aed565b506040519061302782613553565b5465ffffffffffff8116825260301c602082015260405191829182919091602079ffffffffffffffffffffffffffffffffffffffffffffffffffff81604084019565ffffffffffff8151168552015116910152565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576130b3610484565b6130bb6104ab565b6130c3613daa565b6130cb613ed9565b73ffffffffffffffffffffffffffffffffffffffff8216158015613109575b6105c5576130f9913390614850565b6001600d55604051908152602090f35b5073ffffffffffffffffffffffffffffffffffffffff8116156130ea565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761315e610484565b613166613daa565b61316e613ed9565b7f00000000000000000000000000000000000000000000000000000000000000004210612c325773ffffffffffffffffffffffffffffffffffffffff81169081156105c557335f908152601560205260409020916001830192835490811561328c57544210613264576131e081613de3565b92831561323c5783613201915f6106b69755611156612bb885601654613746565b604080519182526020820184905233917f06cc7e90b4f2b554a9614b0caa84f909f3498c820ae47c731f490c28c07f7d3b9181908101611a8b565b7f6ef661ae000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f52c459f9000000000000000000000000000000000000000000000000000000005f5260045ffd5b7e31bd65000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6132ff610484565b613307613b46565b16807fffffffffffffffffffffffff0000000000000000000000000000000000000000600c541617600c5573ffffffffffffffffffffffffffffffffffffffff600b54167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576134046133ab610484565b73ffffffffffffffffffffffffffffffffffffffff6133c86104ab565b916133d1613b1a565b50165f526013602052600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b60016040519161341383613553565b8054808452910154602092830190815260408051928352905192820192909252f35b90600182811c9216801561347c575b602083101461344f57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691613444565b5f929181549161349583613435565b80835292600181169081156134ea57506001146134b157505050565b5f9081526020812093945091925b8383106134d0575060209250010190565b6001816020929493945483858701015201910191906134bf565b905060209495507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091509291921683830152151560051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761356f57604052565b613526565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761356f57604052565b6011546801000000000000000081101561356f5760018101601155601154811015611b025773ffffffffffffffffffffffffffffffffffffffff9060115f5260205f200191167fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9062093a808201809211610e4e57565b90621275008201809211610e4e57565b9060018201809211610e4e57565b91908201809211610e4e57565b90670de0b6b3a7640000820291808304670de0b6b3a76400001490151715610e4e57565b90670429d069189e0000820291808304670429d069189e00001490151715610e4e57565b906127108202918083046127101490151715610e4e57565b9062127500820291808304621275001490151715610e4e57565b81810292918115918404141715610e4e57565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201918211610e4e57565b91908203918211610e4e57565b811561375d570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b60405190613799604083613574565b565b73ffffffffffffffffffffffffffffffffffffffff169073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168214610f9457801561380057613799913390613e7c565b5050565b8115610f6c5761384361383f6138388373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b5460ff1690565b1590565b6139455761386f8173ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b61389183303373ffffffffffffffffffffffffffffffffffffffff8616613e10565b61389a82613f10565b506138ab600482019384549061367f565b91600182016138d36138be825460801c90565b6fffffffffffffffffffffffffffffffff1690565b4210156139395761391b613902612134926138fc600287015491612bb36138be42925460801c90565b90613706565b61391561390e876136d4565b918761367f565b90613753565b10613930575f61392b9455614005565b600190565b50509055600190565b505f61392b9455614005565b7fc52db363000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff165f526013602052600160405f20015460801c8042115f146139a15790565b504290565b73ffffffffffffffffffffffffffffffffffffffff8116156105c5576139f061383f6138388373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b61394557613a1c8173ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b90613a2681613f10565b5060048201918254918215613a7757612134613a7061390260018501613a506138be825460801c90565b421015613a91575b6138fc600287015491612bb36138be42925460801c90565b1015613a7d575b50505050565b5f613a889455614005565b5f808080613a77565b5f8855613a9f878787614005565b613a58565b67ffffffffffffffff811161356f5760051b60200190565b60405190601154808352826020810160115f5260205f20925f5b818110613aeb57505061379992500383613574565b845473ffffffffffffffffffffffffffffffffffffffff16835260019485019487945060209093019201613ad6565b60405190613b2782613553565b5f6020838281520152565b8051821015611b025760209160051b010190565b73ffffffffffffffffffffffffffffffffffffffff600b5416330361197157565b92919073ffffffffffffffffffffffffffffffffffffffff8416938415613d2c5773ffffffffffffffffffffffffffffffffffffffff82168015613d0057613bad613ed9565b613bb682614ff7565b613bbf83614ff7565b805f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f20541615613cf1575b613c0f8273ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5495848710613ca55784613799969703613c468473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b55613c6e8473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b8054860190556040518581527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a3615258565b7fe450d38c000000000000000000000000000000000000000000000000000000005f5273ffffffffffffffffffffffffffffffffffffffff83166004526024879052604485905260645ffd5b613cfb8380614182565b613be8565b7fec442f05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7f96c6fd1e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b65ffffffffffff613d6843614982565b1680821015613d7b575061064190614982565b907fecd3f81e000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b6002600d5414613dbb576002600d55565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b670de0b6b3a7640000810290808204670de0b6b3a76400001490151715610e4e5760105461064191613753565b90919273ffffffffffffffffffffffffffffffffffffffff6137999481604051957f23b872dd000000000000000000000000000000000000000000000000000000006020880152166024860152166044840152606483015260648252613e77608483613574565b614ba3565b6137999273ffffffffffffffffffffffffffffffffffffffff604051937fa9059cbb000000000000000000000000000000000000000000000000000000006020860152166024840152604483015260448252613e77606483613574565b60ff600c5460a01c16613ee857565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b9073ffffffffffffffffffffffffffffffffffffffff82165f52601360205261379960405f206001613f64613f4d613f47876143ca565b9661396d565b8354871480613fe7575b613fa2575b868455614c35565b9101906fffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffff00000000000000000000000000000000825416179055565b83830154613fd190613fc6906fffffffffffffffffffffffffffffffff1683613746565b600286015490613706565b613fe06004860191825461367f565b9055613f5c565b50838301546fffffffffffffffffffffffffffffffff168111613f57565b73ffffffffffffffffffffffffffffffffffffffff9061413e7f9e725a59e293b3a40cf2ae1148796b9ab47f79644276301835a4ee7bf4d80734939460018601906140546138be835460801c90565b804210614164575b50600361407462127500830460028a018190556136ec565b97828980948110614143575b505001556140cd61409042614c35565b82906fffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffff00000000000000000000000000000000825416179055565b6141236140d942613661565b916140e383614c35565b6fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b60405193849316958360209093929193604081019481520152565b0390a2565b61414c91613746565b61415b6004830191825461367f565b90555f83614080565b9061205861417c926138fc60028b0154914290613746565b5f61405c565b9073ffffffffffffffffffffffffffffffffffffffff811690811561424f5773ffffffffffffffffffffffffffffffffffffffff8084165f81815260086020526040812080547fffffffffffffffffffffffff00000000000000000000000000000000000000008116871790915561379996931694614249939290918691907f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9080a473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f205490565b9161503e565b7f41e46dee000000000000000000000000000000000000000000000000000000005f5260045ffd5b61428d670de0b6b3a76400009160105490613706565b0490565b919073ffffffffffffffffffffffffffffffffffffffff83168015613d00576142b8613ed9565b6142c184614ff7565b805f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f205416156143bb575b6142fe6142f98360025461367f565b600255565b6143258473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b8054830190556040518281525f907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a36002549279ffffffffffffffffffffffffffffffffffffffffffffffffffff80851161438b57506137999293506151c5565b7f1cb15d26000000000000000000000000000000000000000000000000000000005f52600485905260245260445ffd5b6143c58480614182565b6142ea565b73ffffffffffffffffffffffffffffffffffffffff81165f52601360205260405f2090600254908115614458576144009061396d565b906fffffffffffffffffffffffffffffffff600184015416828114614451578203918211610e4e57610f1561443d61444593600286015490613706565b93549361368c565b8101809111610e4e5790565b5050505490565b50505490565b73ffffffffffffffffffffffffffffffffffffffff165f52601360205273ffffffffffffffffffffffffffffffffffffffff6144be82600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b91165f525f60205260405f20549081156144ef57548203918211610e4e57670de0b6b3a76400009161428d91613706565b5050505f90565b61455661450282613f10565b809373ffffffffffffffffffffffffffffffffffffffff84165f52601360205261455081600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b9361445e565b600182018054918201809211610e4e575555565b8054806145775750505f90565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810111610e4e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff915f5260205f2001015460301c90565b9161064193916145e093614e6a565b90929192614f30565b73ffffffffffffffffffffffffffffffffffffffff16805f52600760205260405f2080549283916001830190550361461f575050565b7f752d88c0000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b73ffffffffffffffffffffffffffffffffffffffff8116908115613d2c57614673613ed9565b61467c81614ff7565b6146a38173ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5483811061479957906146db84613799959493039173ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5581600254036002555f817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405180602081018782520390a38015614781575b61472d614728836152f7565b61548c565b50505f908152600860205260408120549080527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c75473ffffffffffffffffffffffffffffffffffffffff908116911661503e565b61479261478d836152f7565b61542b565b505061471c565b7fe450d38c000000000000000000000000000000000000000000000000000000005f5273ffffffffffffffffffffffffffffffffffffffff909116600452602452604482905260645ffd5b906147ee82613aa4565b6147fb6040519182613574565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06148298294613aa4565b01905f5b82811061483957505050565b602090614844613b1a565b8282850101520161482d565b73ffffffffffffffffffffffffffffffffffffffff9061487083826144f6565b1691825f52601360205260016148aa83600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b0192835493841561490b575f90556148c3848383613e7c565b7ffad55f843dbd67b821d107dd22535d77fb9384daa21dc35a976588f81997b7b3602073ffffffffffffffffffffffffffffffffffffffff806040519588875216951693a490565b50505050505f90565b73ffffffffffffffffffffffffffffffffffffffff169081156108525773ffffffffffffffffffffffffffffffffffffffff8116156108265761497f915f52600160205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b55565b65ffffffffffff811161499a5765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b600181111561064157806001700100000000000000000000000000000000831015614afd575b614aa3614a99614a8f614a85614a7b614a71614a60614aaa9760048a68010000000000000000614aaf9c1015614af0575b640100000000811015614ae3575b62010000811015614ad6575b610100811015614ac9575b6010811015614abc575b1015614ab4575b60030260011c90565b614a6a818b613753565b0160011c90565b614a6a818a613753565b614a6a8189613753565b614a6a8188613753565b614a6a8187613753565b614a6a8186613753565b8093613753565b821190565b900390565b60011b614a57565b60041c9160021b91614a50565b60081c9160041b91614a46565b60101c9160081b91614a3b565b60201c9160101b91614a2f565b60401c9160201b91614a21565b5050614aaf614aaa614aa3614a99614a8f614a85614a7b614a71614a60614b248a60801c90565b98506801000000000000000097506149f09650505050505050565b91905b838210614b4f5750505090565b9091928083169080841860011c8201809211610e4e57845f5265ffffffffffff8260205f2001541665ffffffffffff8416105f14614b915750925b9190614b42565b939250614b9d90613671565b91614b8a565b905f602091828151910182855af115614c2a575f513d614c21575073ffffffffffffffffffffffffffffffffffffffff81163b155b614bdf5750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b60011415614bd8565b6040513d5f823e3d90fd5b6fffffffffffffffffffffffffffffffff8111614c61576fffffffffffffffffffffffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52608060045260245260445ffd5b60ff8114614cf05760ff811690601f8211614cc85760405191614cb5604084613574565b6020808452838101919036833783525290565b7fb3512b0c000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060405161064181614d03816005613486565b0382613574565b60ff8114614d2e5760ff811690601f8211614cc85760405191614cb5604084613574565b5060405161064181614d03816006613486565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016301480614e41575b15614da9577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a08152614e3b60c082613574565b51902090565b507f00000000000000000000000000000000000000000000000000000000000000004614614d80565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411614eee579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15614c2a575f5173ffffffffffffffffffffffffffffffffffffffff811615614ee457905f905f90565b505f906001905f90565b5050505f9160039190565b60041115614f0357565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b614f3981614ef9565b80614f42575050565b614f4b81614ef9565b60018103614f7b577ff645eedf000000000000000000000000000000000000000000000000000000005f5260045ffd5b614f8481614ef9565b60028103614fb857507ffce698f7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b80614fc4600392614ef9565b14614fcc5750565b7fd78bce0c000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b614fff613abc565b908151915f5b8381106150125750505050565b806150388473ffffffffffffffffffffffffffffffffffffffff61258960019587613b32565b01615005565b919073ffffffffffffffffffffffffffffffffffffffff81169273ffffffffffffffffffffffffffffffffffffffff81169084821415806151bc575b615086575b5050505050565b81615139575b50508261509b575b808061507f565b61512e6151157fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7249361510f61510979ffffffffffffffffffffffffffffffffffffffffffffffffffff9573ffffffffffffffffffffffffffffffffffffffff165f52600960205260405f2090565b916152f7565b906153cb565b6040805192851683529316602082015291829190820190565b0390a25f8080615094565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff6151b26151156151a37fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7249473ffffffffffffffffffffffffffffffffffffffff165f52600960205260405f2090565b6151ac886152f7565b90615367565b0390a25f8061508c565b5083151561507a565b9073ffffffffffffffffffffffffffffffffffffffff613799926151eb61478d846152f7565b5050168015615245575b60086020527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7545f91825260409091205473ffffffffffffffffffffffffffffffffffffffff908116911661503e565b615251614728836152f7565b50506151f5565b9073ffffffffffffffffffffffffffffffffffffffff806137999493169182156152e4575b169081156152d1575b5f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f205416905f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f2054169061503e565b6152dd614728846152f7565b5050615286565b6152f061478d856152f7565b505061527d565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff81116153375779ffffffffffffffffffffffffffffffffffffffffffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f5260d060045260245260445ffd5b9061537143614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806153978561456a565b92169116039079ffffffffffffffffffffffffffffffffffffffffffffffffffff8211610e4e576153c792615580565b9091565b906153d543614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806153fb8561456a565b92169116019079ffffffffffffffffffffffffffffffffffffffffffffffffffff8211610e4e576153c792615580565b61543443614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff8061545b600a61456a565b921691160179ffffffffffffffffffffffffffffffffffffffffffffffffffff8111610e4e576153c791600a615580565b61549543614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806154bc600a61456a565b921691160379ffffffffffffffffffffffffffffffffffffffffffffffffffff8111610e4e576153c791600a615580565b80546801000000000000000081101561356f5761550f91600182018155611aed565b6155545781516020929092015160301b7fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff92909216919091179055565b7f4e487b71000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b80549293928015615676576155976155a291613719565b825f5260205f200190565b8054603081901c9365ffffffffffff9182169291811680841161564e57879303615607575061560392509065ffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000083549260301b169116179055565b9190565b9150506156039161562761561961378a565b65ffffffffffff9093168352565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff861660208301526154ed565b7f2520601d000000000000000000000000000000000000000000000000000000005f5260045ffd5b50906156ae9161568761561961378a565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff851660208301526154ed565b5f919056fea164736f6c634300081a000a000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac000000000000000000000000e2a7de3c3190afd79c49c8e8f2fa30ca78b97dfd00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000076a70000000000000000000000000000000000000000000000000000000000000000135374616b65642054726576656520546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000973746b545245564545000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f3560e01c806305528f4e1461047f57806306fdde031461047a578063095ea7b3146104755780630b670b1a14610470578063156ce5f81461046b57806318160ddd146104665780631c03e6cc14610461578063228fe6171461045c57806323b872dd14610457578063313ce5671461045257806332dac32d1461044d5780633a46b1a8146104485780633ae1786f146104435780633c7176cf1461043e5780633d82e3c1146104395780633f4ba83a146104345780634bf5d7e91461042f578063573761981461042a57806358146d1714610425578063587cde1e146104205780635af06ea71461041b5780635c19a95c146104165780635c745a3d146104115780635c975abb1461040c5780635e580f5f146104075780636e99d52f146103715780636fcfff451461040257806370a08231146103fd578063715018a6146103f8578063727a5d57146103f35780637935f721146103ee57806379ba5097146103e95780637acb7757146103e45780637bb7bed1146103df5780637ecebe00146103da57806383ea2532146103d55780638456cb59146103d057806384b0196e146103cb5780638b1154f0146103c65780638da5cb5b146103c15780638e539e8c146103bc57806391767552146103b757806391ddadf4146103b2578063955bdea1146103ad57806395d89b41146103a8578063968565fc146103a35780639964c09f1461039e5780639ab24eb0146103995780639bca43c0146103945780639caed1d61461038f578063a36849771461038a578063a9059cbb14610385578063ab576cb514610380578063b022418c1461037b578063b287ff8214610376578063c094b1c714610371578063c3cda5201461036c578063c4f59f9b14610367578063c519a7bf14610362578063c55dae631461035d578063cca3ae7214610358578063da27604014610353578063dd62ed3e1461034e578063e30c397814610349578063e7e5af2914610344578063e991560f1461033f578063f1127ed81461033a578063f1e42ccd14610335578063f2888dbb14610330578063f2fde38b1461032b5763f3805cc014610326575f80fd5b613371565b6132b3565b613127565b61307c565b612f88565b612df1565b612d3c565b612ceb565b612c5a565b612aab565b612a53565b6129e5565b612994565b612904565b6127c0565b611608565b612780565b6126cf565b612694565b612645565b61260a565b612596565b6124e5565b61245f565b6123c6565b61238b565b6122c8565b61223d565b6121f4565b6121b8565b6120db565b61208a565b611ecb565b611d13565b611c6a565b611bee565b611b8b565b611b07565b61199d565b611893565b6117d1565b61177f565b611749565b6116e9565b611643565b6115b2565b61156f565b611526565b6114e6565b61146c565b6113f3565b6113b3565b611368565b6112a1565b6111e3565b611024565b610fbc565b610e53565b610d31565b610cf6565b610cbd565b610ba1565b610aac565b61095a565b61091f565b6108e6565b61087e565b61075a565b610644565b6104ce565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036104a757565b5f80fd5b6024359073ffffffffffffffffffffffffffffffffffffffff821682036104a757565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61051a610484565b610522613b46565b1680156105c557805f52601460205260ff60405f20541661059d57805f52601460205261057760405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055565b7f50f7e50b19f1e2e9d15f76be42d5d0eea98162fa39d0c1112c87c1a3e94f80665f80a2005b7f91d703dd000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9fabe1c1000000000000000000000000000000000000000000000000000000005f5260045ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b9060206106419281815201906105ed565b90565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576040515f60035461068281613435565b808452906001811690811561071857506001146106ba575b6106b6836106aa81850382613574565b60405191829182610630565b0390f35b60035f9081527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b939250905b8082106106fe575090915081016020016106aa61069a565b9192600181602092548385880101520191019092916106e6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660208086019190915291151560051b840190910191506106aa905061069a565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610791610484565b60243533156108525773ffffffffffffffffffffffffffffffffffffffff8216918215610826576107ec8291335f52600160205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5560405190815233907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3602060405160018152f35b7f94280d62000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7fe602df05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6108ca610484565b165f526012602052602060ff60405f2054166040519015158152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051600a8152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020600254604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610991610484565b610999613b46565b73ffffffffffffffffffffffffffffffffffffffff81169081156105c5575f8281526012602052604090205460ff16610a8457600a6011541015610a5c5780610a31610a06610a369373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055565b6135b5565b7f94818bcde148f9bd2db48b76249e6439b53c8b7258295eedf1d1008aa66c74ea5f80a2005b7fb0de2a7e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fa51fe5ed000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff610af8610484565b610b00613b46565b1680156105c557805f52601460205260ff60405f20541615610b7957805f526014602052610b5360405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008154169055565b7f7d180af120a8dcd38d344c3bc08e175faf5d1de10457c89bcf45eb5f4514883d5f80a2005b7f017eafa7000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610bd8610484565b610be06104ab565b6044359073ffffffffffffffffffffffffffffffffffffffff83165f526001602052610c2d3360405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8410610c6d575b610c619350613b67565b60405160018152602090f35b828410610c8957610c8483610c6195033383614914565b610c57565b82847ffb8f41b2000000000000000000000000000000000000000000000000000000005f523360045260245260445260645ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405160128152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020601654604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610d68610484565b73ffffffffffffffffffffffffffffffffffffffff60243591165f526009602052610d9660405f2091613d58565b8154905f829160058411610dfb575b610db0935084614b3f565b9081610de057505060205f5b79ffffffffffffffffffffffffffffffffffffffffffffffffffff60405191168152f35b610deb602092613719565b905f52815f20015460301c610dbc565b9192610e06816149ca565b8103908111610e4e57610db093855f5265ffffffffffff8260205f2001541665ffffffffffff8516105f14610e3c575091610da5565b929150610e4890613671565b90610da5565b613624565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757600435610e8d613daa565b73ffffffffffffffffffffffffffffffffffffffff600e54163303610f94578015610f6c57600254906016548201809211610e4e57610ecb82613de3565b91818301809311610e4e5782610f15610f107f8eac21849f07f4ad3ad263a83dafa0f2d3427034f0233fca7f93a10e43d602d095610f0b610f1a9561368c565b61367f565b613719565b613753565b90610f2482601055565b610f508130337f000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac613e10565b604080519182526020820192909252a1610f6a6001600d55565b005b7fe5a74490000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f3d693ada000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611008610484565b165f526014602052602060ff60405f2054166040519015158152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75760043561105e6104ab565b611066613daa565b73ffffffffffffffffffffffffffffffffffffffff600e54163303610f945781908215610f6c5773ffffffffffffffffffffffffffffffffffffffff8116156105c5576110b4600f54613651565b42106111bb576106b6926110cd6002546016549061367f565b906110d782613de3565b906110f26110e4836136b0565b670de0b6b3a7640000900490565b8091116111b1575b509161117c84611143610f0b610f15610f106111949761113b867f4f5f38ee30b01a960b4dfdcd520a3ca59c1a664a32dcfe5418ca79b0de6b72369b613746565b93849161368c565b9261114d84601055565b61115642600f55565b7f000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac613e7c565b60408051858152602081019290925290918291820190565b0390a16111a16001600d55565b6040519081529081906020820190565b935061117c6110fa565b7f61beb0bb000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611219613b46565b600c5460ff8160a01c1615611279577fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600c557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576112d843614982565b65ffffffffffff806112e943614982565b16911603611340576106b6604051611302604082613574565b601d81527f6d6f64653d626c6f636b6e756d6265722666726f6d3d64656661756c7400000060208201526040519182916020835260208301906105ed565b7f6ff07140000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610f6a6113a2610484565b602435906113ae613b46565b61379b565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051670de0b6b3a76400008152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61143f610484565b165f526008602052602073ffffffffffffffffffffffffffffffffffffffff60405f205416604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576114a3610484565b6024356114ae613daa565b6114b6613ed9565b335f52601460205260ff60405f20541615610f94576114d491613804565b6001600d556040519015158152602090f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757610f6a611520610484565b33614182565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567611562610484565b61396d565b604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060ff600c5460a01c166040519015158152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576116016115ec610484565b6115f4613daa565b6115fc613ed9565b6139a6565b6001600d55005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051621275008152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61168f610484565b165f52600960205260405f205463ffffffff81116116b95760405163ffffffff9091168152602090f35b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52602060045260245260445ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567611725610484565b73ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f205490565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576104a7613b46565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020670de0b6b3a76400006117c860043560105490613706565b04604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff61181d610484565b611825613b46565b1680156105c55773ffffffffffffffffffffffffffffffffffffffff600e54827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600e55167f5941313b333454ac6c9554eecf88be0f00f3da0e321b673ee0614b916df2d75b5f80a3005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7573373ffffffffffffffffffffffffffffffffffffffff600c541603611971577fffffffffffffffffffffffff0000000000000000000000000000000000000000600c5416600c55600b54337fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600b5573ffffffffffffffffffffffffffffffffffffffff3391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576004356119d76104ab565b906119e0613daa565b6119e8613ed9565b8015610f6c5773ffffffffffffffffffffffffffffffffffffffff821680156105c557611a378230337f000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac613e10565b611a4082614277565b8015611a9857611a53816106b695614291565b60408051848152602081019290925233917f6c86f3fd5118b3aa8bb4f389a617046de0a3d3d477de1a1673d227f802f616dc91819081015b0390a36111a16001600d55565b7f7d5c26d4000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b8054821015611b02575f5260205f2001905f90565b611ac0565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576004356011548110156104a75773ffffffffffffffffffffffffffffffffffffffff60209160115f527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68015416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611bd7610484565b165f526007602052602060405f2054604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff611c3a610484565b165f52601560205260405f2060018154910154906106b66040519283928360209093929193604081019481520152565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611ca0613b46565b611ca8613ed9565b740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff600c541617600c557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611e0f611d6d7f5374616b65642054726576656520546f6b656e00000000000000000000000013614c91565b611d967f3100000000000000000000000000000000000000000000000000000000000001614d0a565b6020604051611da58282613574565b5f815281611e1d818301947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe083013687376040519788977f0f00000000000000000000000000000000000000000000000000000000000000895260e0858a015260e08901906105ed565b9087820360408901526105ed565b914660608701523060808701525f60a087015285830360c087015251918281520192915f5b828110611e5157505050500390f35b835185528695509381019392810192600101611e42565b60206040818301928281528451809452019201905f5b818110611e8b5750505090565b9091926020604082611ec060019488516020809173ffffffffffffffffffffffffffffffffffffffff81511684520151910152565b019401929101611e7e565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757611f02610484565b611f0a613abc565b90815190611f1782613aa4565b92611f256040519485613574565b8284527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611f5284613aa4565b015f5b8181106120735750505f5b838110611f7557604051806106b68782611e68565b80611fc8611fa2611f8860019486613b32565b5173ffffffffffffffffffffffffffffffffffffffff1690565b611fac8389613b32565b519073ffffffffffffffffffffffffffffffffffffffff169052565b61205e8261202a866005612006611fe2611f88888b613b32565b73ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b015461205861203c611f888588613b32565b8761205261204d611f88888b613b32565b6143ca565b9161445e565b9061367f565b602061206a8389613b32565b51015201611f60565b60209061207e613b1a565b82828901015201611f55565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600b5416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612115600435613d58565b600a54905f829160058411612164575b6121319350600a614b3f565b8061214257506040515f8152602090f35b61215f612150602092613719565b600a5f52825f20015460301c90565b610dbc565b919261216f816149ca565b8103908111610e4e5761213193600a5f5265ffffffffffff8260205f2001541665ffffffffffff8516105f146121a6575091612125565b9291506121b290613671565b90612125565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020611567600435613de3565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602061222d43614982565b65ffffffffffff60405191168152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612273613daa565b61227b613ed9565b612283613abc565b80515f5b818110612295576001600d55005b806122c173ffffffffffffffffffffffffffffffffffffffff6122ba60019487613b32565b5116613f10565b5001612287565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576040515f60045461230681613435565b8084529060018116908115610718575060011461232d576106b6836106aa81850382613574565b60045f9081527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b939250905b808210612371575090915081016020016106aa61069a565b919260018160209254838588010152019101909291612359565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020600f54604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576123fd610484565b6124056104ab565b61240d613daa565b612415613ed9565b73ffffffffffffffffffffffffffffffffffffffff8216158015612441575b6105c557611601916144f6565b5073ffffffffffffffffffffffffffffffffffffffff811615612434565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6124ab610484565b165f526009602052602079ffffffffffffffffffffffffffffffffffffffffffffffffffff6124dc60405f2061456a565b16604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761251c610484565b612524613daa565b61252c613ed9565b73ffffffffffffffffffffffffffffffffffffffff8116156105c557612550613abc565b8051905f5b828110612563576001600d55005b806125908573ffffffffffffffffffffffffffffffffffffffff61258960019587613b32565b51166144f6565b01612555565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576125cd610484565b6125d5613daa565b6125dd613ed9565b73ffffffffffffffffffffffffffffffffffffffff8116156105c55761260290613f10565b506001600d55005b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020601054604051908152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761268961267f610484565b6024359033613b67565b602060405160018152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405162093a808152f35b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612706610484565b61276c6127116104ab565b9173ffffffffffffffffffffffffffffffffffffffff81165f526013602052600161276084600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b015492612052826143ca565b8101809111610e4e57602090604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020604051670429d069189e00008152f35b346104a75760c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576127f7610484565b6044359060243560643560ff811681036104a75760843560a435918542116128d857916128cc916128d3936042610f6a9860405160208101917fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf835273ffffffffffffffffffffffffffffffffffffffff8b16604083015289606083015260808201526080815261288960a082613574565b519020612894614d41565b90604051917f1901000000000000000000000000000000000000000000000000000000000000835260028301526022820152206145d1565b91826145e9565b614182565b857f4683af0e000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761293a613abc565b6040518091602082016020835281518091526020604084019201905f5b818110612965575050500390f35b825173ffffffffffffffffffffffffffffffffffffffff16845285945060209384019390920191600101612957565b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600e5416604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac168152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75760206040517f00000000000000000000000000000000000000000000000000000000695f63df8152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757600435612ae5613daa565b612aed613ed9565b7f00000000000000000000000000000000000000000000000000000000695f63df4210612c3257335f52601560205260405f2060018101805491612b5883612b523373ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5461367f565b8411612c0a5783612be592612bbd612bb8867fa345023a4eda421d4dbe108023f197e12ac173da60a22f9c5a82765eff7f4bf99785115f14612bf257612ba7612ba18287613746565b3361464d565b612bb38560165461367f565b613746565b601655565b612bc642613661565b8093555560405191829133958360209093929193604081019481520152565b0390a2610f6a6001600d55565b612c05612bff8683613746565b33614291565b612ba7565b7f96ab19c8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fba8d8234000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576020612ce2612c96610484565b73ffffffffffffffffffffffffffffffffffffffff612cb36104ab565b91165f526001835260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604051908152f35b346104a7575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757602073ffffffffffffffffffffffffffffffffffffffff600c5416604051908152f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff612d88610484565b165f5260136020526fffffffffffffffffffffffffffffffff60405f208054600182015491600281015490600460038201549101549160405195869560c087019587528180821616602088015260801c1660408601526060850152608084015260a08301520390f35b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612e28610484565b612e30613daa565b612e38613ed9565b73ffffffffffffffffffffffffffffffffffffffff811680156105c557612e5d613abc565b90815191612e6a836147e4565b93612e7433614ff7565b5f5b848110612e97576106b686612e8b6001600d55565b60405191829182611e68565b6001908482612eb2336005612006611fe2611f88888c613b32565b01805490612ed0612ec6611f88868a613b32565b611fac868d613b32565b816020612edd868d613b32565b51015281612eef575b50505001612e76565b5f9055612f258186612f20612f07611f88888c613b32565b73ffffffffffffffffffffffffffffffffffffffff1690565b613e7c565b73ffffffffffffffffffffffffffffffffffffffff612f47611f888589613b32565b167ffad55f843dbd67b821d107dd22535d77fb9384daa21dc35a976588f81997b7b360405180612f7d3395829190602083019252565b0390a4845f80612ee6565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a757612fbf610484565b6024359063ffffffff821682036104a7576106b69173ffffffffffffffffffffffffffffffffffffffff61301992612ff5613b1a565b50612ffe613b1a565b50165f52600960205260405f20613013613b1a565b50611aed565b506040519061302782613553565b5465ffffffffffff8116825260301c602082015260405191829182919091602079ffffffffffffffffffffffffffffffffffffffffffffffffffff81604084019565ffffffffffff8151168552015116910152565b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576130b3610484565b6130bb6104ab565b6130c3613daa565b6130cb613ed9565b73ffffffffffffffffffffffffffffffffffffffff8216158015613109575b6105c5576130f9913390614850565b6001600d55604051908152602090f35b5073ffffffffffffffffffffffffffffffffffffffff8116156130ea565b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75761315e610484565b613166613daa565b61316e613ed9565b7f00000000000000000000000000000000000000000000000000000000695f63df4210612c325773ffffffffffffffffffffffffffffffffffffffff81169081156105c557335f908152601560205260409020916001830192835490811561328c57544210613264576131e081613de3565b92831561323c5783613201915f6106b69755611156612bb885601654613746565b604080519182526020820184905233917f06cc7e90b4f2b554a9614b0caa84f909f3498c820ae47c731f490c28c07f7d3b9181908101611a8b565b7f6ef661ae000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f52c459f9000000000000000000000000000000000000000000000000000000005f5260045ffd5b7e31bd65000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a75773ffffffffffffffffffffffffffffffffffffffff6132ff610484565b613307613b46565b16807fffffffffffffffffffffffff0000000000000000000000000000000000000000600c541617600c5573ffffffffffffffffffffffffffffffffffffffff600b54167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346104a75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104a7576134046133ab610484565b73ffffffffffffffffffffffffffffffffffffffff6133c86104ab565b916133d1613b1a565b50165f526013602052600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b60016040519161341383613553565b8054808452910154602092830190815260408051928352905192820192909252f35b90600182811c9216801561347c575b602083101461344f57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691613444565b5f929181549161349583613435565b80835292600181169081156134ea57506001146134b157505050565b5f9081526020812093945091925b8383106134d0575060209250010190565b6001816020929493945483858701015201910191906134bf565b905060209495507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091509291921683830152151560051b010190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761356f57604052565b613526565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761356f57604052565b6011546801000000000000000081101561356f5760018101601155601154811015611b025773ffffffffffffffffffffffffffffffffffffffff9060115f5260205f200191167fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9062093a808201809211610e4e57565b90621275008201809211610e4e57565b9060018201809211610e4e57565b91908201809211610e4e57565b90670de0b6b3a7640000820291808304670de0b6b3a76400001490151715610e4e57565b90670429d069189e0000820291808304670429d069189e00001490151715610e4e57565b906127108202918083046127101490151715610e4e57565b9062127500820291808304621275001490151715610e4e57565b81810292918115918404141715610e4e57565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201918211610e4e57565b91908203918211610e4e57565b811561375d570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b60405190613799604083613574565b565b73ffffffffffffffffffffffffffffffffffffffff169073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac168214610f9457801561380057613799913390613e7c565b5050565b8115610f6c5761384361383f6138388373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b5460ff1690565b1590565b6139455761386f8173ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b61389183303373ffffffffffffffffffffffffffffffffffffffff8616613e10565b61389a82613f10565b506138ab600482019384549061367f565b91600182016138d36138be825460801c90565b6fffffffffffffffffffffffffffffffff1690565b4210156139395761391b613902612134926138fc600287015491612bb36138be42925460801c90565b90613706565b61391561390e876136d4565b918761367f565b90613753565b10613930575f61392b9455614005565b600190565b50509055600190565b505f61392b9455614005565b7fc52db363000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff165f526013602052600160405f20015460801c8042115f146139a15790565b504290565b73ffffffffffffffffffffffffffffffffffffffff8116156105c5576139f061383f6138388373ffffffffffffffffffffffffffffffffffffffff165f52601260205260405f2090565b61394557613a1c8173ffffffffffffffffffffffffffffffffffffffff165f52601360205260405f2090565b90613a2681613f10565b5060048201918254918215613a7757612134613a7061390260018501613a506138be825460801c90565b421015613a91575b6138fc600287015491612bb36138be42925460801c90565b1015613a7d575b50505050565b5f613a889455614005565b5f808080613a77565b5f8855613a9f878787614005565b613a58565b67ffffffffffffffff811161356f5760051b60200190565b60405190601154808352826020810160115f5260205f20925f5b818110613aeb57505061379992500383613574565b845473ffffffffffffffffffffffffffffffffffffffff16835260019485019487945060209093019201613ad6565b60405190613b2782613553565b5f6020838281520152565b8051821015611b025760209160051b010190565b73ffffffffffffffffffffffffffffffffffffffff600b5416330361197157565b92919073ffffffffffffffffffffffffffffffffffffffff8416938415613d2c5773ffffffffffffffffffffffffffffffffffffffff82168015613d0057613bad613ed9565b613bb682614ff7565b613bbf83614ff7565b805f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f20541615613cf1575b613c0f8273ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5495848710613ca55784613799969703613c468473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b55613c6e8473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b8054860190556040518581527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a3615258565b7fe450d38c000000000000000000000000000000000000000000000000000000005f5273ffffffffffffffffffffffffffffffffffffffff83166004526024879052604485905260645ffd5b613cfb8380614182565b613be8565b7fec442f05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7f96c6fd1e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b65ffffffffffff613d6843614982565b1680821015613d7b575061064190614982565b907fecd3f81e000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b6002600d5414613dbb576002600d55565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b670de0b6b3a7640000810290808204670de0b6b3a76400001490151715610e4e5760105461064191613753565b90919273ffffffffffffffffffffffffffffffffffffffff6137999481604051957f23b872dd000000000000000000000000000000000000000000000000000000006020880152166024860152166044840152606483015260648252613e77608483613574565b614ba3565b6137999273ffffffffffffffffffffffffffffffffffffffff604051937fa9059cbb000000000000000000000000000000000000000000000000000000006020860152166024840152604483015260448252613e77606483613574565b60ff600c5460a01c16613ee857565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b9073ffffffffffffffffffffffffffffffffffffffff82165f52601360205261379960405f206001613f64613f4d613f47876143ca565b9661396d565b8354871480613fe7575b613fa2575b868455614c35565b9101906fffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffff00000000000000000000000000000000825416179055565b83830154613fd190613fc6906fffffffffffffffffffffffffffffffff1683613746565b600286015490613706565b613fe06004860191825461367f565b9055613f5c565b50838301546fffffffffffffffffffffffffffffffff168111613f57565b73ffffffffffffffffffffffffffffffffffffffff9061413e7f9e725a59e293b3a40cf2ae1148796b9ab47f79644276301835a4ee7bf4d80734939460018601906140546138be835460801c90565b804210614164575b50600361407462127500830460028a018190556136ec565b97828980948110614143575b505001556140cd61409042614c35565b82906fffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffff00000000000000000000000000000000825416179055565b6141236140d942613661565b916140e383614c35565b6fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b60405193849316958360209093929193604081019481520152565b0390a2565b61414c91613746565b61415b6004830191825461367f565b90555f83614080565b9061205861417c926138fc60028b0154914290613746565b5f61405c565b9073ffffffffffffffffffffffffffffffffffffffff811690811561424f5773ffffffffffffffffffffffffffffffffffffffff8084165f81815260086020526040812080547fffffffffffffffffffffffff00000000000000000000000000000000000000008116871790915561379996931694614249939290918691907f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9080a473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f205490565b9161503e565b7f41e46dee000000000000000000000000000000000000000000000000000000005f5260045ffd5b61428d670de0b6b3a76400009160105490613706565b0490565b919073ffffffffffffffffffffffffffffffffffffffff83168015613d00576142b8613ed9565b6142c184614ff7565b805f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f205416156143bb575b6142fe6142f98360025461367f565b600255565b6143258473ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b8054830190556040518281525f907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a36002549279ffffffffffffffffffffffffffffffffffffffffffffffffffff80851161438b57506137999293506151c5565b7f1cb15d26000000000000000000000000000000000000000000000000000000005f52600485905260245260445ffd5b6143c58480614182565b6142ea565b73ffffffffffffffffffffffffffffffffffffffff81165f52601360205260405f2090600254908115614458576144009061396d565b906fffffffffffffffffffffffffffffffff600184015416828114614451578203918211610e4e57610f1561443d61444593600286015490613706565b93549361368c565b8101809111610e4e5790565b5050505490565b50505490565b73ffffffffffffffffffffffffffffffffffffffff165f52601360205273ffffffffffffffffffffffffffffffffffffffff6144be82600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b91165f525f60205260405f20549081156144ef57548203918211610e4e57670de0b6b3a76400009161428d91613706565b5050505f90565b61455661450282613f10565b809373ffffffffffffffffffffffffffffffffffffffff84165f52601360205261455081600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b9361445e565b600182018054918201809211610e4e575555565b8054806145775750505f90565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810111610e4e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff915f5260205f2001015460301c90565b9161064193916145e093614e6a565b90929192614f30565b73ffffffffffffffffffffffffffffffffffffffff16805f52600760205260405f2080549283916001830190550361461f575050565b7f752d88c0000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b73ffffffffffffffffffffffffffffffffffffffff8116908115613d2c57614673613ed9565b61467c81614ff7565b6146a38173ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5483811061479957906146db84613799959493039173ffffffffffffffffffffffffffffffffffffffff165f525f60205260405f2090565b5581600254036002555f817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405180602081018782520390a38015614781575b61472d614728836152f7565b61548c565b50505f908152600860205260408120549080527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c75473ffffffffffffffffffffffffffffffffffffffff908116911661503e565b61479261478d836152f7565b61542b565b505061471c565b7fe450d38c000000000000000000000000000000000000000000000000000000005f5273ffffffffffffffffffffffffffffffffffffffff909116600452602452604482905260645ffd5b906147ee82613aa4565b6147fb6040519182613574565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06148298294613aa4565b01905f5b82811061483957505050565b602090614844613b1a565b8282850101520161482d565b73ffffffffffffffffffffffffffffffffffffffff9061487083826144f6565b1691825f52601360205260016148aa83600560405f20019073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b0192835493841561490b575f90556148c3848383613e7c565b7ffad55f843dbd67b821d107dd22535d77fb9384daa21dc35a976588f81997b7b3602073ffffffffffffffffffffffffffffffffffffffff806040519588875216951693a490565b50505050505f90565b73ffffffffffffffffffffffffffffffffffffffff169081156108525773ffffffffffffffffffffffffffffffffffffffff8116156108265761497f915f52600160205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b55565b65ffffffffffff811161499a5765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b600181111561064157806001700100000000000000000000000000000000831015614afd575b614aa3614a99614a8f614a85614a7b614a71614a60614aaa9760048a68010000000000000000614aaf9c1015614af0575b640100000000811015614ae3575b62010000811015614ad6575b610100811015614ac9575b6010811015614abc575b1015614ab4575b60030260011c90565b614a6a818b613753565b0160011c90565b614a6a818a613753565b614a6a8189613753565b614a6a8188613753565b614a6a8187613753565b614a6a8186613753565b8093613753565b821190565b900390565b60011b614a57565b60041c9160021b91614a50565b60081c9160041b91614a46565b60101c9160081b91614a3b565b60201c9160101b91614a2f565b60401c9160201b91614a21565b5050614aaf614aaa614aa3614a99614a8f614a85614a7b614a71614a60614b248a60801c90565b98506801000000000000000097506149f09650505050505050565b91905b838210614b4f5750505090565b9091928083169080841860011c8201809211610e4e57845f5265ffffffffffff8260205f2001541665ffffffffffff8416105f14614b915750925b9190614b42565b939250614b9d90613671565b91614b8a565b905f602091828151910182855af115614c2a575f513d614c21575073ffffffffffffffffffffffffffffffffffffffff81163b155b614bdf5750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b60011415614bd8565b6040513d5f823e3d90fd5b6fffffffffffffffffffffffffffffffff8111614c61576fffffffffffffffffffffffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52608060045260245260445ffd5b60ff8114614cf05760ff811690601f8211614cc85760405191614cb5604084613574565b6020808452838101919036833783525290565b7fb3512b0c000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060405161064181614d03816005613486565b0382613574565b60ff8114614d2e5760ff811690601f8211614cc85760405191614cb5604084613574565b5060405161064181614d03816006613486565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000003ba32287b008ddf3c5a38df272369931e303015216301480614e41575b15614da9577fbcb5a382c4fc1964255b01eb4b5f01caf0d2146d8b0c1621d39af6693472c41e90565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527fbb3feb650fdc1ddb549af1e6461a3cae980247b5d44beffdf360ffade8711a6360408201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260a08152614e3b60c082613574565b51902090565b507f00000000000000000000000000000000000000000000000000000000000000924614614d80565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411614eee579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa15614c2a575f5173ffffffffffffffffffffffffffffffffffffffff811615614ee457905f905f90565b505f906001905f90565b5050505f9160039190565b60041115614f0357565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b614f3981614ef9565b80614f42575050565b614f4b81614ef9565b60018103614f7b577ff645eedf000000000000000000000000000000000000000000000000000000005f5260045ffd5b614f8481614ef9565b60028103614fb857507ffce698f7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b80614fc4600392614ef9565b14614fcc5750565b7fd78bce0c000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b614fff613abc565b908151915f5b8381106150125750505050565b806150388473ffffffffffffffffffffffffffffffffffffffff61258960019587613b32565b01615005565b919073ffffffffffffffffffffffffffffffffffffffff81169273ffffffffffffffffffffffffffffffffffffffff81169084821415806151bc575b615086575b5050505050565b81615139575b50508261509b575b808061507f565b61512e6151157fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7249361510f61510979ffffffffffffffffffffffffffffffffffffffffffffffffffff9573ffffffffffffffffffffffffffffffffffffffff165f52600960205260405f2090565b916152f7565b906153cb565b6040805192851683529316602082015291829190820190565b0390a25f8080615094565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff6151b26151156151a37fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7249473ffffffffffffffffffffffffffffffffffffffff165f52600960205260405f2090565b6151ac886152f7565b90615367565b0390a25f8061508c565b5083151561507a565b9073ffffffffffffffffffffffffffffffffffffffff613799926151eb61478d846152f7565b5050168015615245575b60086020527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7545f91825260409091205473ffffffffffffffffffffffffffffffffffffffff908116911661503e565b615251614728836152f7565b50506151f5565b9073ffffffffffffffffffffffffffffffffffffffff806137999493169182156152e4575b169081156152d1575b5f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f205416905f52600860205273ffffffffffffffffffffffffffffffffffffffff60405f2054169061503e565b6152dd614728846152f7565b5050615286565b6152f061478d856152f7565b505061527d565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff81116153375779ffffffffffffffffffffffffffffffffffffffffffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f5260d060045260245260445ffd5b9061537143614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806153978561456a565b92169116039079ffffffffffffffffffffffffffffffffffffffffffffffffffff8211610e4e576153c792615580565b9091565b906153d543614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806153fb8561456a565b92169116019079ffffffffffffffffffffffffffffffffffffffffffffffffffff8211610e4e576153c792615580565b61543443614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff8061545b600a61456a565b921691160179ffffffffffffffffffffffffffffffffffffffffffffffffffff8111610e4e576153c791600a615580565b61549543614982565b9079ffffffffffffffffffffffffffffffffffffffffffffffffffff806154bc600a61456a565b921691160379ffffffffffffffffffffffffffffffffffffffffffffffffffff8111610e4e576153c791600a615580565b80546801000000000000000081101561356f5761550f91600182018155611aed565b6155545781516020929092015160301b7fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff92909216919091179055565b7f4e487b71000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b80549293928015615676576155976155a291613719565b825f5260205f200190565b8054603081901c9365ffffffffffff9182169291811680841161564e57879303615607575061560392509065ffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000083549260301b169116179055565b9190565b9150506156039161562761561961378a565b65ffffffffffff9093168352565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff861660208301526154ed565b7f2520601d000000000000000000000000000000000000000000000000000000005f5260045ffd5b50906156ae9161568761561961378a565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff851660208301526154ed565b5f919056fea164736f6c634300081a000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac000000000000000000000000e2a7de3c3190afd79c49c8e8f2fa30ca78b97dfd00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000076a70000000000000000000000000000000000000000000000000000000000000000135374616b65642054726576656520546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000973746b545245564545000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _baseToken (address): 0xe90FE2DE4A415aD48B6DcEc08bA6ae98231948Ac
Arg [1] : _slashingAdmin (address): 0xE2a7De3C3190AFd79C49C8E8f2Fa30Ca78B97DFd
Arg [2] : _name (string): Staked Trevee Token
Arg [3] : _symbol (string): stkTREVEE
Arg [4] : _version (string): 1
Arg [5] : _freezePeriod (uint256): 7776000
-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 000000000000000000000000e90fe2de4a415ad48b6dcec08ba6ae98231948ac
Arg [1] : 000000000000000000000000e2a7de3c3190afd79c49c8e8f2fa30ca78b97dfd
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [5] : 000000000000000000000000000000000000000000000000000000000076a700
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000013
Arg [7] : 5374616b65642054726576656520546f6b656e00000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [9] : 73746b5452455645450000000000000000000000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [11] : 3100000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.