Source Code
Latest 25 from a total of 244 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Unstake | 20021088 | 609 days ago | IN | 0 ETH | 0.0008747 | ||||
| Unbond | 19752615 | 646 days ago | IN | 0 ETH | 0.00026886 | ||||
| Unstake | 19640788 | 662 days ago | IN | 0 ETH | 0.00242864 | ||||
| Unstake | 19640787 | 662 days ago | IN | 0 ETH | 0.00246192 | ||||
| Unstake | 19640787 | 662 days ago | IN | 0 ETH | 0.00246159 | ||||
| Unbond | 19206244 | 723 days ago | IN | 0 ETH | 0.0014752 | ||||
| Unbond | 19206244 | 723 days ago | IN | 0 ETH | 0.0014752 | ||||
| Unbond | 19206243 | 723 days ago | IN | 0 ETH | 0.00146592 | ||||
| Unstake | 19181836 | 726 days ago | IN | 0 ETH | 0.00378934 | ||||
| Unstake | 19148658 | 731 days ago | IN | 0 ETH | 0.0020035 | ||||
| Unbond | 19062184 | 743 days ago | IN | 0 ETH | 0.00083537 | ||||
| Unstake | 18925252 | 762 days ago | IN | 0 ETH | 0.00106259 | ||||
| Unstake | 18789642 | 781 days ago | IN | 0 ETH | 0.00347717 | ||||
| Unbond | 18754801 | 786 days ago | IN | 0 ETH | 0.00150277 | ||||
| Unstake | 18711844 | 792 days ago | IN | 0 ETH | 0.00371268 | ||||
| Unstake | 18594713 | 809 days ago | IN | 0 ETH | 0.0023894 | ||||
| Unbond | 18593018 | 809 days ago | IN | 0 ETH | 0.00245988 | ||||
| Unbond | 18593014 | 809 days ago | IN | 0 ETH | 0.0024891 | ||||
| Unstake | 18540862 | 816 days ago | IN | 0 ETH | 0.00269154 | ||||
| Unstake | 18505095 | 821 days ago | IN | 0 ETH | 0.00140444 | ||||
| Unstake | 18505088 | 821 days ago | IN | 0 ETH | 0.0014129 | ||||
| Unbond | 18505083 | 821 days ago | IN | 0 ETH | 0.00092511 | ||||
| Claim All | 18503412 | 822 days ago | IN | 0 ETH | 0.00126658 | ||||
| Claim All | 18503409 | 822 days ago | IN | 0 ETH | 0.00064006 | ||||
| Unstake | 18421996 | 833 days ago | IN | 0 ETH | 0.00212812 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
CellarStaking
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;
import { ERC20 } from "src/base/ERC20.sol";
import { SafeTransferLib } from "src/base/SafeTransferLib.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { ICellarStaking } from "src/interfaces/ICellarStaking.sol";
import "./Errors.sol";
/**
* @title Sommelier Staking
* @author Kevin Kennis
*
* Staking for Sommelier Cellars.
*
* This contract is inspired by the Synthetix staking rewards contract, Ampleforth's
* token geyser, and Treasure DAO's MAGIC mine. However, there are unique improvements
* and new features, specifically unbonding, as inspired by LP bonding on Osmosis.
* Unbonding allows the contract to guarantee deposits for a certain amount of time,
* increasing predictability and stickiness of TVL for Cellars.
*
* *********************************** Funding Flow ***********************************
*
* 1) The contract owner calls 'notifyRewardAmount' to specify an initial schedule of rewards
* The contract should hold enough the distribution token to fund the
* specified reward schedule, where the length of the reward schedule is defined by
* epochDuration. This duration can also be changed by the owner, and any change will apply
* to future calls to 'notifyRewardAmount' (but will not affect active schedules).
* 2) At a future time, the contract owner may call 'notifyRewardAmount' again to extend the
* staking program with new rewards. These new schedules may distribute more or less
* rewards than previous epochs. If a previous epoch is not finished, any leftover rewards
* get rolled into the new schedule, increasing the reward rate. Reward schedules always
* end exactly 'epochDuration' seconds from the most recent time 'notifyRewardAmount' has been
* called.
*
* ********************************* Staking Lifecycle ********************************
*
* 1) A user may deposit a certain amount of tokens to stake, and is required to lock
* those tokens for a specified amount of time. There are three locking options:
* one day, one week, or one month. Longer locking times receive larger 'boosts',
* that the deposit will receive a larger proportional amount of shares. A user
* may not unstake until they choose to unbond, and time defined by the lock has
* elapsed during unbonding.
* 2) When a user wishes to withdraw, they must first "unbond" their stake, which starts
* a timer equivalent to the lock time. They still receive their rewards during this
* time, but forfeit any locktime boosts. A user may cancel the unbonding period at any
* time to regain their boosts, which will set the unbonding timer back to 0.
* 2) Once the lock has elapsed, a user may unstake their deposit, either partially
* or in full. The user will continue to receive the same 'boosted' amount of rewards
* until they unstake. The user may unstake all of their deposits at once, as long
* as all of the lock times have elapsed. When unstaking, the user will also receive
* all eligible rewards for all deposited stakes, which accumulate linearly.
* 3) At any time, a user may claim their available rewards for their deposits. Rewards
* accumulate linearly and can be claimed at any time, whether or not the lock has
* for a given deposit has expired. The user can claim rewards for a specific deposit,
* or may choose to collect all eligible rewards at once.
*
* ************************************ Accounting ************************************
*
* The contract uses an accounting mechanism based on the 'rewardPerToken' model,
* originated by the Synthetix staking rewards contract. First, token deposits are accounted
* for, with synthetic "boosted" amounts used for reward calculations. As time passes,
* rewardPerToken continues to accumulate, whereas the value of 'rewardPerToken' will match
* the reward due to a single token deposited before the first ever rewards were scheduled.
*
* At each accounting checkpoint, rewardPerToken will be recalculated, and every time an
* existing stake is 'touched', this value is used to calculate earned rewards for that
* stake. Each stake tracks a 'rewardPerTokenPaid' value, which represents the 'rewardPerToken'
* value the last time the stake calculated "earned" rewards. Every recalculation pays the difference.
* This ensures no earning is double-counted. When a new stake is deposited, its
* initial 'rewardPerTokenPaid' is set to the current 'rewardPerToken' in the contract,
* ensuring it will not receive any rewards emitted during the period before deposit.
*
* The following example applies to a given epoch of 100 seconds, with a reward rate
* of 100 tokens per second:
*
* a) User 1 deposits a stake of 50 before the epoch begins
* b) User 2 deposits a stake of 20 at second 20 of the epoch
* c) User 3 deposits a stake of 100 at second 50 of the epoch
*
* In this case,
*
* a) At second 20, before User 2's deposit, rewardPerToken will be 40
* (2000 total tokens emitted over 20 seconds / 50 staked).
* b) At second 50, before User 3's deposit, rewardPerToken will be 82.857
* (previous 40 + 3000 tokens emitted over 30 seconds / 70 staked == 42.857)
* c) At second 100, when the period is over, rewardPerToken will be 112.267
* (previous 82.857 + 5000 tokens emitted over 50 seconds / 170 staked == 29.41)
*
*
* Then, each user will receive rewards proportional to the their number of tokens. At second 100:
* a) User 1 will receive 50 * 112.267 = 5613.35 rewards
* b) User 2 will receive 20 * (112.267 - 40) = 1445.34
* (40 is deducted because it was the current rewardPerToken value on deposit)
* c) User 3 will receive 100 * (112.267 - 82.857) = 2941
* (82.857 is deducted because it was the current rewardPerToken value on deposit)
*
* Depending on deposit times, this accumulation may take place over multiple
* reward periods, and the total rewards earned is simply the sum of rewards earned for
* each period. A user may also have multiple discrete deposits, which are all
* accounted for separately due to timelocks and locking boosts. Therefore,
* a user's total earned rewards are a function of their rewards across
* the proportional tokens deposited, across different ranges of rewardPerToken.
*
* Reward accounting takes place before every operation which may change
* accounting calculations (minting of new shares on staking, burning of
* shares on unstaking, or claiming, which decrements eligible rewards).
* This is gas-intensive but unavoidable, since retroactive accounting
* based on previous proportionate shares would require a prohibitive
* amount of storage of historical state. On every accounting run, there
* are a number of safety checks to ensure that all reward tokens are
* accounted for and that no accounting time periods have been missed.
*
*/
contract CellarStaking is ICellarStaking, Ownable {
using SafeTransferLib for ERC20;
// ============================================ STATE ==============================================
// ============== Constants ==============
uint256 public constant ONE = 1e18;
uint256 public constant ONE_DAY = 60 * 60 * 24;
uint256 public constant ONE_WEEK = ONE_DAY * 7;
uint256 public constant TWO_WEEKS = ONE_WEEK * 2;
uint256 public immutable SHORT_BOOST;
uint256 public immutable MEDIUM_BOOST;
uint256 public immutable LONG_BOOST;
uint256 public immutable SHORT_BOOST_TIME;
uint256 public immutable MEDIUM_BOOST_TIME;
uint256 public immutable LONG_BOOST_TIME;
// ============ Global State =============
ERC20 public immutable override stakingToken;
ERC20 public immutable override distributionToken;
uint256 public override currentEpochDuration;
uint256 public override nextEpochDuration;
uint256 public override rewardsReady;
uint256 public override minimumDeposit;
uint256 public override endTimestamp;
uint256 public override totalDeposits;
uint256 public override totalDepositsWithBoost;
uint256 public override rewardRate;
uint256 public override rewardPerTokenStored;
uint256 private lastAccountingTimestamp = block.timestamp;
/// @notice Emergency states in case of contract malfunction.
bool public override paused;
bool public override ended;
bool public override claimable;
// ============= User State ==============
/// @notice user => all user's staking positions
mapping(address => UserStake[]) public stakes;
// ========================================== CONSTRUCTOR ===========================================
/**
* @param _owner The owner of the staking contract - will immediately receive ownership.
* @param _stakingToken The token users will deposit in order to stake.
* @param _distributionToken The token the staking contract will distribute as rewards.
* @param _epochDuration The length of a reward schedule.
* @param shortBoost The boost multiplier for the short unbonding time.
* @param mediumBoost The boost multiplier for the medium unbonding time.
* @param longBoost The boost multiplier for the long unbonding time.
* @param shortBoostTime The short unbonding time.
* @param mediumBoostTime The medium unbonding time.
* @param longBoostTime The long unbonding time.
*/
constructor(
address _owner,
ERC20 _stakingToken,
ERC20 _distributionToken,
uint256 _epochDuration,
uint256 shortBoost,
uint256 mediumBoost,
uint256 longBoost,
uint256 shortBoostTime,
uint256 mediumBoostTime,
uint256 longBoostTime
) {
stakingToken = _stakingToken;
distributionToken = _distributionToken;
nextEpochDuration = _epochDuration;
SHORT_BOOST = shortBoost;
MEDIUM_BOOST = mediumBoost;
LONG_BOOST = longBoost;
SHORT_BOOST_TIME = shortBoostTime;
MEDIUM_BOOST_TIME = mediumBoostTime;
LONG_BOOST_TIME = longBoostTime;
transferOwnership(_owner);
}
// ======================================= STAKING OPERATIONS =======================================
/**
* @notice Make a new deposit into the staking contract. Longer locks receive reward boosts.
* @dev Specified amount of stakingToken must be approved for withdrawal by the caller.
* @dev Valid lock values are 0 (one day), 1 (one week), and 2 (two weeks).
*
* @param amount The amount of the stakingToken to stake.
* @param lock The amount of time to lock stake for.
*/
function stake(uint256 amount, Lock lock) external override whenNotPaused updateRewards {
if (amount == 0) revert USR_ZeroDeposit();
if (amount < minimumDeposit) revert USR_MinimumDeposit(amount, minimumDeposit);
if (totalDeposits == 0 && rewardsReady > 0) {
_startProgram(rewardsReady);
rewardsReady = 0;
// Need to run updateRewards again
_updateRewards();
} else if (block.timestamp > endTimestamp) {
revert STATE_NoRewardsLeft();
}
// Do share accounting and populate user stake information
(uint256 boost, ) = _getBoost(lock);
uint256 amountWithBoost = amount + ((amount * boost) / ONE);
stakes[msg.sender].push(
UserStake({
amount: uint112(amount),
amountWithBoost: uint112(amountWithBoost),
unbondTimestamp: 0,
rewardPerTokenPaid: uint112(rewardPerTokenStored),
rewards: 0,
lock: lock
})
);
// Update global state
totalDeposits += amount;
totalDepositsWithBoost += amountWithBoost;
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Stake(msg.sender, stakes[msg.sender].length - 1, amount);
}
/**
* @notice Unbond a specified amount from a certain deposited stake.
* @dev After the unbond time elapses, the deposit can be unstaked.
*
* @param depositId The specified deposit to unstake from.
*
*/
function unbond(uint256 depositId) external override whenNotPaused updateRewards {
_unbond(depositId);
}
/**
* @notice Unbond all user deposits.
* @dev Different deposits may have different timelocks.
*
*/
function unbondAll() external override whenNotPaused updateRewards {
// Individually unbond each deposit
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
if (s.amount != 0 && s.unbondTimestamp == 0) {
_unbond(i);
}
}
}
/**
* @dev Contains all logic for processing an unbond operation.
* For the given deposit, sets an unlock time, and
* reverts boosts to 0.
*
* @param depositId The specified deposit to unbond from.
*/
function _unbond(uint256 depositId) internal {
// Fetch stake and make sure it is withdrawable
UserStake storage s = stakes[msg.sender][depositId];
uint256 depositAmount = s.amount;
if (depositAmount == 0) revert USR_NoDeposit(depositId);
if (s.unbondTimestamp > 0) revert USR_AlreadyUnbonding(depositId);
_updateRewardForStake(msg.sender, depositId);
// Remove any lock boosts
uint256 depositAmountReduced = s.amountWithBoost - depositAmount;
(, uint256 lockDuration) = _getBoost(s.lock);
s.amountWithBoost = uint112(depositAmount);
s.unbondTimestamp = uint32(block.timestamp + lockDuration);
totalDepositsWithBoost -= uint112(depositAmountReduced);
emit Unbond(msg.sender, depositId, depositAmount);
}
/**
* @notice Cancel an unbonding period for a stake that is currently unbonding.
* @dev Resets the unbonding timer and reinstates any lock boosts.
*
* @param depositId The specified deposit to unstake from.
*
*/
function cancelUnbonding(uint256 depositId) external override whenNotPaused updateRewards {
_cancelUnbonding(depositId);
}
/**
* @notice Cancel an unbonding period for all stakes.
* @dev Only cancels stakes that are unbonding.
*
*/
function cancelUnbondingAll() external override whenNotPaused updateRewards {
// Individually unbond each deposit
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
if (s.amount != 0 && s.unbondTimestamp != 0) {
_cancelUnbonding(i);
}
}
}
/**
* @dev Contains all logic for cancelling an unbond operation.
* For the given deposit, resets the unbonding timer, and
* reverts boosts to amount determined by lock.
*
* @param depositId The specified deposit to unbond from.
*/
function _cancelUnbonding(uint256 depositId) internal {
// Fetch stake and make sure it is withdrawable
UserStake storage s = stakes[msg.sender][depositId];
uint256 depositAmount = s.amount;
if (depositAmount == 0) revert USR_NoDeposit(depositId);
if (s.unbondTimestamp == 0) revert USR_NotUnbonding(depositId);
_updateRewardForStake(msg.sender, depositId);
// Reinstate
(uint256 boost, ) = _getBoost(s.lock);
uint256 depositAmountIncreased = (s.amount * boost) / ONE;
uint256 amountWithBoost = s.amount + depositAmountIncreased;
s.amountWithBoost = uint112(amountWithBoost);
s.unbondTimestamp = 0;
totalDepositsWithBoost += depositAmountIncreased;
emit CancelUnbond(msg.sender, depositId);
}
/**
* @notice Unstake a specific deposited stake.
* @dev The unbonding time for the specified deposit must have elapsed.
* @dev Unstaking automatically claims available rewards for the deposit.
*
* @param depositId The specified deposit to unstake from.
*
* @return reward The amount of accumulated rewards since the last reward claim.
*/
function unstake(uint256 depositId) external override whenNotPaused updateRewards returns (uint256 reward) {
return _unstake(depositId);
}
/**
* @notice Unstake all user deposits.
* @dev Only unstakes rewards that are unbonded.
* @dev Unstaking automatically claims all available rewards.
*
* @return rewards The amount of accumulated rewards since the last reward claim.
*/
function unstakeAll() external override whenNotPaused updateRewards returns (uint256[] memory) {
// Individually unstake each deposit
UserStake[] storage userStakes = stakes[msg.sender];
uint256[] memory rewards = new uint256[](userStakes.length);
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
if (s.amount != 0 && s.unbondTimestamp != 0 && block.timestamp >= s.unbondTimestamp) {
rewards[i] = _unstake(i);
}
}
return rewards;
}
/**
* @dev Contains all logic for processing an unstake operation.
* For the given deposit, does share accounting and burns
* shares, returns staking tokens to the original owner,
* updates global deposit and share trackers, and claims
* rewards for the given deposit.
*
* @param depositId The specified deposit to unstake from.
*/
function _unstake(uint256 depositId) internal returns (uint256 reward) {
// Fetch stake and make sure it is withdrawable
UserStake storage s = stakes[msg.sender][depositId];
uint256 depositAmount = s.amount;
if (depositAmount == 0) revert USR_NoDeposit(depositId);
if (s.unbondTimestamp == 0 || block.timestamp < s.unbondTimestamp) revert USR_StakeLocked(depositId);
_updateRewardForStake(msg.sender, depositId);
// Start unstaking
reward = s.rewards;
s.amount = 0;
s.amountWithBoost = 0;
s.rewards = 0;
// Update global state
// Boosted amount same as deposit amount, since we have unbonded
totalDeposits -= depositAmount;
totalDepositsWithBoost -= depositAmount;
// Distribute stake
stakingToken.safeTransfer(msg.sender, depositAmount);
// Distribute reward
distributionToken.safeTransfer(msg.sender, reward);
emit Unstake(msg.sender, depositId, depositAmount, reward);
}
/**
* @notice Claim rewards for a given deposit.
* @dev Rewards accumulate linearly since deposit.
*
* @param depositId The specified deposit for which to claim rewards.
*
* @return reward The amount of accumulated rewards since the last reward claim.
*/
function claim(uint256 depositId) external override whenNotPaused updateRewards returns (uint256 reward) {
return _claim(depositId);
}
/**
* @notice Claim all available rewards.
* @dev Rewards accumulate linearly.
*
*
* @return rewards The amount of accumulated rewards since the last reward claim.
* Each element of the array specified rewards for the corresponding
* indexed deposit.
*/
function claimAll() external override whenNotPaused updateRewards returns (uint256[] memory rewards) {
// Individually claim for each stake
UserStake[] storage userStakes = stakes[msg.sender];
rewards = new uint256[](userStakes.length);
for (uint256 i = 0; i < userStakes.length; i++) {
rewards[i] = _claim(i);
}
}
/**
* @dev Contains all logic for processing a claim operation.
* Relies on previous reward accounting done before
* processing external functions. Updates the amount
* of rewards claimed so rewards cannot be claimed twice.
*
*
* @param depositId The specified deposit to claim rewards for.
*
* @return reward The amount of accumulated rewards since the last reward claim.
*/
function _claim(uint256 depositId) internal returns (uint256 reward) {
// Fetch stake and make sure it is valid
UserStake storage s = stakes[msg.sender][depositId];
_updateRewardForStake(msg.sender, depositId);
reward = s.rewards;
// Distribute reward
if (reward > 0) {
s.rewards = 0;
distributionToken.safeTransfer(msg.sender, reward);
emit Claim(msg.sender, depositId, reward);
}
}
/**
* @notice Unstake and return all staked tokens to the caller.
* @dev In emergency mode, staking time locks do not apply.
*/
function emergencyUnstake() external override {
if (!ended) revert STATE_NoEmergencyUnstake();
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
if (claimable) _updateRewardForStake(msg.sender, i);
UserStake storage s = userStakes[i];
uint256 amount = s.amount;
if (amount > 0) {
// Update global state
totalDeposits -= amount;
totalDepositsWithBoost -= s.amountWithBoost;
s.amount = 0;
s.amountWithBoost = 0;
stakingToken.transfer(msg.sender, amount);
emit EmergencyUnstake(msg.sender, i, amount);
}
}
}
/**
* @notice Claim any accumulated rewards in emergency mode.
* @dev In emergency node, no additional reward accounting is done.
* Rewards do not accumulate after emergency mode begins,
* so any earned amount is only retroactive to when the contract
* was active.
*/
function emergencyClaim() external override {
if (!ended) revert STATE_NoEmergencyUnstake();
if (!claimable) revert STATE_NoEmergencyClaim();
uint256 reward;
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
_updateRewardForStake(msg.sender, i);
UserStake storage s = userStakes[i];
reward += s.rewards;
s.rewards = 0;
}
if (reward > 0) {
distributionToken.safeTransfer(msg.sender, reward);
// No need for per-stake events like emergencyUnstake:
// don't need to make sure positions were unwound
emit EmergencyClaim(msg.sender, reward);
}
}
// ======================================== ADMIN OPERATIONS ========================================
/**
* @notice Specify a new schedule for staking rewards. Contract must already hold enough tokens.
* @dev Can only be called by reward distributor. Owner must approve distributionToken for withdrawal.
* @dev epochDuration must divide reward evenly, otherwise any remainder will be lost.
*
* @param reward The amount of rewards to distribute per second.
*/
function notifyRewardAmount(uint256 reward) external override onlyOwner updateRewards {
if (block.timestamp < endTimestamp) {
uint256 remaining = endTimestamp - block.timestamp;
uint256 leftover = remaining * rewardRate;
reward += leftover;
}
if (reward < nextEpochDuration) revert USR_ZeroRewardsPerEpoch();
uint256 rewardBalance = distributionToken.balanceOf(address(this));
uint256 pendingRewards = reward + rewardsReady;
if (rewardBalance < pendingRewards) revert STATE_RewardsNotFunded(rewardBalance, pendingRewards);
// prevent overflow when computing rewardPerToken
uint256 proposedRewardRate = reward / nextEpochDuration;
if (proposedRewardRate >= ((type(uint256).max / ONE) / nextEpochDuration)) {
revert USR_RewardTooLarge();
}
if (totalDeposits == 0) {
// No deposits yet, so keep rewards pending until first deposit
// Incrementing in case it is called twice
rewardsReady += reward;
} else {
// Ready to start
_startProgram(reward);
}
lastAccountingTimestamp = block.timestamp;
}
/**
* @notice Change the length of a reward epoch for future reward schedules.
*
* @param _epochDuration The new duration for reward schedules.
*/
function setRewardsDuration(uint256 _epochDuration) external override onlyOwner {
if (rewardsReady > 0) revert STATE_RewardsReady();
nextEpochDuration = _epochDuration;
emit EpochDurationChange(nextEpochDuration);
}
/**
* @notice Specify a minimum deposit for staking.
* @dev Can only be called by owner.
*
* @param _minimum The minimum deposit for each new stake.
*/
function setMinimumDeposit(uint256 _minimum) external override onlyOwner {
minimumDeposit = _minimum;
}
/**
* @notice Pause the contract. Pausing prevents staking, unstaking, claiming
* rewards, and scheduling new rewards. Should only be used
* in an emergency.
*
* @param _paused Whether the contract should be paused.
*/
function setPaused(bool _paused) external override onlyOwner {
paused = _paused;
}
/**
* @notice Stops the contract - this is irreversible. Should only be used
* in an emergency, for example an irreversible accounting bug
* or an exploit. Enables all depositors to withdraw their stake
* instantly. Also stops new rewards accounting.
*
* @param makeRewardsClaimable Whether any previously accumulated rewards should be claimable.
*/
function emergencyStop(bool makeRewardsClaimable) external override onlyOwner {
if (ended) revert STATE_AlreadyShutdown();
// Update state and put in irreversible emergency mode
ended = true;
claimable = makeRewardsClaimable;
uint256 amountToReturn = distributionToken.balanceOf(address(this));
if (makeRewardsClaimable) {
// Update rewards one more time
_updateRewards();
// Return any remaining, since new calculation is stopped
uint256 remaining = endTimestamp > block.timestamp ? (endTimestamp - block.timestamp) * rewardRate : 0;
// Make sure any rewards except for remaining are kept for claims
uint256 amountToKeep = rewardRate * currentEpochDuration - remaining;
amountToReturn -= amountToKeep;
}
// Send distribution token back to owner
distributionToken.transfer(msg.sender, amountToReturn);
emit EmergencyStop(msg.sender, makeRewardsClaimable);
}
// ======================================= STATE INFORMATION =======================================
/**
* @notice Returns the latest time to account for in the reward program.
*
* @return timestamp The latest time to calculate.
*/
function latestRewardsTimestamp() public view override returns (uint256) {
return block.timestamp < endTimestamp ? block.timestamp : endTimestamp;
}
/**
* @notice Returns the amount of reward to distribute per currently-depostied token.
* Will update on changes to total deposit balance or reward rate.
* @dev Sets rewardPerTokenStored.
*
*
* @return newRewardPerTokenStored The new rewards to distribute per token.
* @return latestTimestamp The latest time to calculate.
*/
function rewardPerToken() public view override returns (uint256 newRewardPerTokenStored, uint256 latestTimestamp) {
latestTimestamp = latestRewardsTimestamp();
if (totalDeposits == 0) return (rewardPerTokenStored, latestTimestamp);
uint256 timeElapsed = latestTimestamp - lastAccountingTimestamp;
uint256 rewardsForTime = timeElapsed * rewardRate;
uint256 newRewardsPerToken = (rewardsForTime * ONE) / totalDepositsWithBoost;
newRewardPerTokenStored = rewardPerTokenStored + newRewardsPerToken;
}
/**
* @notice Gets all of a user's stakes.
* @dev This is provided because Solidity converts public arrays into index getters,
* but we need a way to allow external contracts and users to access the whole array.
* @param user The user whose stakes to get.
*
* @return stakes Array of all user's stakes
*/
function getUserStakes(address user) public view override returns (UserStake[] memory) {
return stakes[user];
}
// ============================================ HELPERS ============================================
/**
* @dev Modifier to apply reward updates before functions that change accounts.
*/
modifier updateRewards() {
_updateRewards();
_;
}
/**
* @dev Blocks calls if contract is paused or killed.
*/
modifier whenNotPaused() {
if (paused) revert STATE_ContractPaused();
if (ended) revert STATE_ContractKilled();
_;
}
/**
* @dev Update reward accounting for the global state totals.
*/
function _updateRewards() internal {
(rewardPerTokenStored, lastAccountingTimestamp) = rewardPerToken();
}
/**
* @dev On initial deposit, start the rewards program.
*
* @param reward The pending rewards to start distributing.
*/
function _startProgram(uint256 reward) internal {
// Assumptions
// Total deposits are now (mod current tx), no ongoing program
// Rewards are already funded (since checked in notifyRewardAmount)
rewardRate = reward / nextEpochDuration;
endTimestamp = block.timestamp + nextEpochDuration;
currentEpochDuration = nextEpochDuration;
emit Funding(reward, endTimestamp);
}
/**
* @dev Update reward for a specific user stake.
*/
function _updateRewardForStake(address user, uint256 depositId) internal {
UserStake storage s = stakes[user][depositId];
if (s.amount == 0) return;
uint256 earned = _earned(s);
s.rewards += uint112(earned);
s.rewardPerTokenPaid = uint112(rewardPerTokenStored);
}
/**
* @dev Return how many rewards a stake has earned and has claimable.
*/
function _earned(UserStake memory s) internal view returns (uint256) {
uint256 rewardPerTokenAcc = rewardPerTokenStored - s.rewardPerTokenPaid;
uint256 newRewards = (s.amountWithBoost * rewardPerTokenAcc) / ONE;
return newRewards;
}
/**
* @dev Maps Lock enum values to corresponding lengths of time and reward boosts.
*/
function _getBoost(Lock _lock) internal view returns (uint256 boost, uint256 timelock) {
if (_lock == Lock.short) {
return (SHORT_BOOST, SHORT_BOOST_TIME);
} else if (_lock == Lock.medium) {
return (MEDIUM_BOOST, MEDIUM_BOOST_TIME);
} else if (_lock == Lock.long) {
return (LONG_BOOST, LONG_BOOST_TIME);
} else {
revert USR_InvalidLockValue(uint256(_lock));
}
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal INITIAL_CHAIN_ID;
bytes32 internal INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import { ERC20 } from "src/base/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
require(success, "TRANSFER_FROM_FAILED");
}
function safeTransfer(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "TRANSFER_FAILED");
}
function safeApprove(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "APPROVE_FAILED");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.16;
import { ERC20 } from "src/base/ERC20.sol";
/**
* @title Sommelier Staking Interface
* @author Kevin Kennis
*
* @notice Full documentation in implementation contract.
*/
interface ICellarStaking {
// ===================== Events =======================
event Funding(uint256 rewardAmount, uint256 rewardEnd);
event Stake(address indexed user, uint256 depositId, uint256 amount);
event Unbond(address indexed user, uint256 depositId, uint256 amount);
event CancelUnbond(address indexed user, uint256 depositId);
event Unstake(address indexed user, uint256 depositId, uint256 amount, uint256 reward);
event Claim(address indexed user, uint256 depositId, uint256 amount);
event EmergencyStop(address owner, bool claimable);
event EmergencyUnstake(address indexed user, uint256 depositId, uint256 amount);
event EmergencyClaim(address indexed user, uint256 amount);
event EpochDurationChange(uint256 duration);
// ===================== Structs ======================
enum Lock {
short,
medium,
long
}
struct UserStake {
uint112 amount;
uint112 amountWithBoost;
uint32 unbondTimestamp;
uint112 rewardPerTokenPaid;
uint112 rewards;
Lock lock;
}
// ============== Public State Variables ==============
function stakingToken() external returns (ERC20);
function distributionToken() external returns (ERC20);
function currentEpochDuration() external returns (uint256);
function nextEpochDuration() external returns (uint256);
function rewardsReady() external returns (uint256);
function minimumDeposit() external returns (uint256);
function endTimestamp() external returns (uint256);
function totalDeposits() external returns (uint256);
function totalDepositsWithBoost() external returns (uint256);
function rewardRate() external returns (uint256);
function rewardPerTokenStored() external returns (uint256);
function paused() external returns (bool);
function ended() external returns (bool);
function claimable() external returns (bool);
// ================ User Functions ================
function stake(uint256 amount, Lock lock) external;
function unbond(uint256 depositId) external;
function unbondAll() external;
function cancelUnbonding(uint256 depositId) external;
function cancelUnbondingAll() external;
function unstake(uint256 depositId) external returns (uint256 reward);
function unstakeAll() external returns (uint256[] memory rewards);
function claim(uint256 depositId) external returns (uint256 reward);
function claimAll() external returns (uint256[] memory rewards);
function emergencyUnstake() external;
function emergencyClaim() external;
// ================ Admin Functions ================
function notifyRewardAmount(uint256 reward) external;
function setRewardsDuration(uint256 _epochDuration) external;
function setMinimumDeposit(uint256 _minimum) external;
function setPaused(bool _paused) external;
function emergencyStop(bool makeRewardsClaimable) external;
// ================ View Functions ================
function latestRewardsTimestamp() external view returns (uint256);
function rewardPerToken() external view returns (uint256, uint256);
function getUserStakes(address user) external view returns (UserStake[] memory);
}// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.16; // ========================================== USER ERRORS =========================================== /** * @dev These errors represent invalid user input to functions. Where appropriate, the invalid value * is specified along with constraints. These errors can be resolved by callers updating their * arguments. */ /** * @notice Attempted an action with zero assets. */ error USR_ZeroAssets(); /** * @notice Attempted an action with zero shares. */ error USR_ZeroShares(); /** * @notice Attempted deposit more than the max deposit. * @param assets the assets user attempted to deposit * @param maxDeposit the max assets that can be deposited */ error USR_DepositRestricted(uint256 assets, uint256 maxDeposit); /** * @notice Attempted to transfer more active shares than the user has. * @param activeShares amount of shares user has * @param attemptedActiveShares amount of shares user tried to transfer */ error USR_NotEnoughActiveShares(uint256 activeShares, uint256 attemptedActiveShares); /** * @notice Attempted swap into an asset that is not the current asset of the position. * @param assetOut address of the asset attempted to swap to * @param currentAsset address of the current asset of position */ error USR_InvalidSwap(address assetOut, address currentAsset); /** * @notice Attempted to sweep an asset that is managed by the cellar. * @param token address of the token that can't be sweeped */ error USR_ProtectedAsset(address token); /** * @notice Attempted rebalance into the same position. * @param position address of the position */ error USR_SamePosition(address position); /** * @notice Attempted to update the position to one that is not supported by the platform. * @param unsupportedPosition address of the unsupported position */ error USR_UnsupportedPosition(address unsupportedPosition); /** * @notice Attempted an operation on an untrusted position. * @param position address of the position */ error USR_UntrustedPosition(address position); /** * @notice Attempted to update a position to an asset that uses an incompatible amount of decimals. * @param newDecimals decimals of precision that the new position uses * @param maxDecimals maximum decimals of precision for a position to be compatible with the cellar */ error USR_TooManyDecimals(uint8 newDecimals, uint8 maxDecimals); /** * @notice User attempted to stake zero amout. */ error USR_ZeroDeposit(); /** * @notice User attempted to stake an amount smaller than the minimum deposit. * * @param amount Amount user attmpted to stake. * @param minimumDeposit The minimum deopsit amount accepted. */ error USR_MinimumDeposit(uint256 amount, uint256 minimumDeposit); /** * @notice The specified deposit ID does not exist for the caller. * * @param depositId The deposit ID provided for lookup. */ error USR_NoDeposit(uint256 depositId); /** * @notice The user is attempting to cancel unbonding for a deposit which is not unbonding. * * @param depositId The deposit ID the user attempted to cancel. */ error USR_NotUnbonding(uint256 depositId); /** * @notice The user is attempting to unbond a deposit which has already been unbonded. * * @param depositId The deposit ID the user attempted to unbond. */ error USR_AlreadyUnbonding(uint256 depositId); /** * @notice The user is attempting to unstake a deposit which is still timelocked. * * @param depositId The deposit ID the user attempted to unstake. */ error USR_StakeLocked(uint256 depositId); /** * @notice The contract owner attempted to update rewards but the new reward rate would cause overflow. */ error USR_RewardTooLarge(); /** * @notice The reward distributor attempted to update rewards but 0 rewards per epoch. * This can also happen if there is less than 1 wei of rewards per second of the * epoch - due to integer division this will also lead to 0 rewards. */ error USR_ZeroRewardsPerEpoch(); /** * @notice The caller attempted to stake with a lock value that did not * correspond to a valid staking time. * * @param lock The provided lock value. */ error USR_InvalidLockValue(uint256 lock); /** * @notice The caller attempted an signed action with an invalid signature. * @param signatureLength length of the signature passed in * @param expectedSignatureLength expected length of the signature passed in */ error USR_InvalidSignature(uint256 signatureLength, uint256 expectedSignatureLength); /** * @notice Attempted an action by a non-custodian */ error USR_NotCustodian(); // ========================================== STATE ERRORS =========================================== /** * @dev These errors represent actions that are being prevented due to current contract state. * These errors do not relate to user input, and may or may not be resolved by other actions * or the progression of time. */ /** * @notice Attempted an action when cellar is using an asset that has a fee on transfer. * @param assetWithFeeOnTransfer address of the asset with fee on transfer */ error STATE_AssetUsesFeeOnTransfer(address assetWithFeeOnTransfer); /** * @notice Attempted action was prevented due to contract being shutdown. */ error STATE_ContractShutdown(); /** * @notice Attempted to shutdown the contract when it was already shutdown. */ error STATE_AlreadyShutdown(); /** * @notice The caller attempted to start a reward period, but the contract did not have enough tokens * for the specified amount of rewards. * * @param rewardBalance The amount of distributionToken held by the contract. * @param reward The amount of rewards the caller attempted to distribute. */ error STATE_RewardsNotFunded(uint256 rewardBalance, uint256 reward); /** * @notice Attempted an operation that is prohibited while yield is still being distributed from the last accrual. */ error STATE_AccrualOngoing(); /** * @notice The caller attempted to change the epoch length, but current reward epochs were active. */ error STATE_RewardsOngoing(); /** * @notice The caller attempted to change the next epoch duration, but there are rewards ready. */ error STATE_RewardsReady(); /** * @notice The caller attempted to deposit stake, but there are no remaining rewards to pay out. */ error STATE_NoRewardsLeft(); /** * @notice The caller attempted to perform an an emergency unstake, but the contract * is not in emergency mode. */ error STATE_NoEmergencyUnstake(); /** * @notice The caller attempted to perform an an emergency unstake, but the contract * is not in emergency mode, or the emergency mode does not allow claiming rewards. */ error STATE_NoEmergencyClaim(); /** * @notice The caller attempted to perform a state-mutating action (e.g. staking or unstaking) * while the contract was paused. */ error STATE_ContractPaused(); /** * @notice The caller attempted to perform a state-mutating action (e.g. staking or unstaking) * while the contract was killed (placed in emergency mode). * @dev Emergency mode is irreversible. */ error STATE_ContractKilled();
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}{
"remappings": [
"@balancer-labs/=lib/balancer-v2-monorepo/../../node_modules/@balancer-labs/",
"@balancer/=lib/balancer-v2-monorepo/pkg/",
"@chainlink/=lib/chainlink/",
"@ds-test/=lib/forge-std/lib/ds-test/src/",
"@forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@solmate/=lib/solmate/src/",
"@uniswap/v3-core/=lib/v3-core/",
"@uniswap/v3-periphery/=lib/v3-periphery/",
"@uniswapV3C/=lib/v3-core/contracts/",
"@uniswapV3P/=lib/v3-periphery/contracts/",
"axelar-gmp-sdk-solidity/=lib/axelar-gmp-sdk-solidity/contracts/",
"balancer-v2-monorepo/=lib/balancer-v2-monorepo/",
"chainlink/=lib/chainlink/integration-tests/contracts/ethereum/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solmate/=lib/solmate/src/",
"v3-core/=lib/v3-core/contracts/",
"v3-periphery/=lib/v3-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract ERC20","name":"_stakingToken","type":"address"},{"internalType":"contract ERC20","name":"_distributionToken","type":"address"},{"internalType":"uint256","name":"_epochDuration","type":"uint256"},{"internalType":"uint256","name":"shortBoost","type":"uint256"},{"internalType":"uint256","name":"mediumBoost","type":"uint256"},{"internalType":"uint256","name":"longBoost","type":"uint256"},{"internalType":"uint256","name":"shortBoostTime","type":"uint256"},{"internalType":"uint256","name":"mediumBoostTime","type":"uint256"},{"internalType":"uint256","name":"longBoostTime","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"STATE_AlreadyShutdown","type":"error"},{"inputs":[],"name":"STATE_ContractKilled","type":"error"},{"inputs":[],"name":"STATE_ContractPaused","type":"error"},{"inputs":[],"name":"STATE_NoEmergencyClaim","type":"error"},{"inputs":[],"name":"STATE_NoEmergencyUnstake","type":"error"},{"inputs":[],"name":"STATE_NoRewardsLeft","type":"error"},{"inputs":[{"internalType":"uint256","name":"rewardBalance","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"STATE_RewardsNotFunded","type":"error"},{"inputs":[],"name":"STATE_RewardsReady","type":"error"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"USR_AlreadyUnbonding","type":"error"},{"inputs":[{"internalType":"uint256","name":"lock","type":"uint256"}],"name":"USR_InvalidLockValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minimumDeposit","type":"uint256"}],"name":"USR_MinimumDeposit","type":"error"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"USR_NoDeposit","type":"error"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"USR_NotUnbonding","type":"error"},{"inputs":[],"name":"USR_RewardTooLarge","type":"error"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"USR_StakeLocked","type":"error"},{"inputs":[],"name":"USR_ZeroDeposit","type":"error"},{"inputs":[],"name":"USR_ZeroRewardsPerEpoch","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"CancelUnbond","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bool","name":"claimable","type":"bool"}],"name":"EmergencyStop","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"EpochDurationChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardEnd","type":"uint256"}],"name":"Funding","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unbond","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Unstake","type":"event"},{"inputs":[],"name":"LONG_BOOST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LONG_BOOST_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MEDIUM_BOOST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MEDIUM_BOOST_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_WEEK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SHORT_BOOST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SHORT_BOOST_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TWO_WEEKS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"cancelUnbonding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelUnbondingAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"claim","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimAll","outputs":[{"internalType":"uint256[]","name":"rewards","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributionToken","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"makeRewardsClaimable","type":"bool"}],"name":"emergencyStop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyUnstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ended","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserStakes","outputs":[{"components":[{"internalType":"uint112","name":"amount","type":"uint112"},{"internalType":"uint112","name":"amountWithBoost","type":"uint112"},{"internalType":"uint32","name":"unbondTimestamp","type":"uint32"},{"internalType":"uint112","name":"rewardPerTokenPaid","type":"uint112"},{"internalType":"uint112","name":"rewards","type":"uint112"},{"internalType":"enum ICellarStaking.Lock","name":"lock","type":"uint8"}],"internalType":"struct ICellarStaking.UserStake[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRewardsTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextEpochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"newRewardPerTokenStored","type":"uint256"},{"internalType":"uint256","name":"latestTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsReady","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimum","type":"uint256"}],"name":"setMinimumDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum ICellarStaking.Lock","name":"lock","type":"uint8"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakes","outputs":[{"internalType":"uint112","name":"amount","type":"uint112"},{"internalType":"uint112","name":"amountWithBoost","type":"uint112"},{"internalType":"uint32","name":"unbondTimestamp","type":"uint32"},{"internalType":"uint112","name":"rewardPerTokenPaid","type":"uint112"},{"internalType":"uint112","name":"rewards","type":"uint112"},{"internalType":"enum ICellarStaking.Lock","name":"lock","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDepositsWithBoost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"unbond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unbondAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"unstake","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstakeAll","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
61018060405242600a553480156200001657600080fd5b5060405162002b5038038062002b508339810160408190526200003991620001e0565b620000443362000099565b6001600160a01b03808a16610140528816610160526002879055608086905260a085905260c084905260e0839052610100829052610120819052620000898a620000e9565b505050505050505050506200027a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b620000f36200016c565b6001600160a01b0381166200015e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b620001698162000099565b50565b6000546001600160a01b03163314620001c85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000155565b565b6001600160a01b03811681146200016957600080fd5b6000806000806000806000806000806101408b8d0312156200020157600080fd5b8a516200020e81620001ca565b60208c0151909a506200022181620001ca565b60408c01519099506200023481620001ca565b8098505060608b0151965060808b0151955060a08b0151945060c08b0151935060e08b015192506101008b015191506101208b015190509295989b9194979a5092959850565b60805160a05160c05160e051610100516101205161014051610160516128076200034960003960008181610511015281816107110152818161080d01528181610e550152818161117101528181612270015261235e01526000818161041701528181610b800152818161144b015261223c0152600081816105380152611cc201526000818161049f0152611c5f01526000818161057b0152611bfc01526000818161046f0152611ca00152600081816103330152611c3d0152600081816105b40152611bda01526128076000f3fe608060405234801561001057600080fd5b50600436106102955760003560e01c80637b0a47ee11610167578063af38d757116100ce578063cc1a378f11610087578063cc1a378f146105e5578063cd3daf9d146105f8578063d1058e5914610615578063df136d651461061d578063e78ec42e14610626578063f2fde38b1461063957600080fd5b8063af38d75714610563578063b5bc32bd14610576578063b98fe9471461059d578063baaa17f2146105a6578063bdb16286146105af578063c2ee3a08146105d657600080fd5b80638da5cb5b116101205780638da5cb5b146104eb5780638e6f6b77146104fc578063934d1fa4146105045780639d1390621461050c578063a827710014610533578063a85adeab1461055a57600080fd5b80637b0a47ee146104615780637bafd02d1461046a5780637d882097146104915780638220155b1461049a578063842e2981146104c1578063863e76db146104e157600080fd5b806335322f371161020b578063636bfbab116101c4578063636bfbab146103f8578063657bab8814610401578063715018a61461040a57806372f702f3146104125780637589cf2f14610451578063785f51801461045957600080fd5b806335322f3714610383578063379607f5146103985780633c6b16ab146103ab578063584b62a1146103be5780635c975abb146103e35780635ef73e24146103f057600080fd5b806315f7b4021161025d57806315f7b4021461031357806316c38b3c1461031b578063190ad7631461032e57806327de9e32146103555780632b8278ca146103685780632e17de781461037057600080fd5b80630a72f2ea1461029a5780630ac62e02146102af5780630d06e528146102c257806310087fb1146102de57806312fa6feb146102f1575b600080fd5b6102ad6102a836600461246d565b61064c565b005b6102ad6102bd366004612494565b6106ad565b6102cb60035481565b6040519081526020015b60405180910390f35b6102ad6102ec3660046124b8565b6108c1565b600b5461030390610100900460ff1681565b60405190151581526020016102d5565b6102ad610c03565b6102ad610329366004612494565b610ce3565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6102ad61036336600461246d565b610cfe565b6102ad610d5c565b6102cb61037e36600461246d565b610eb5565b61038b610f1e565b6040516102d591906124ec565b6102cb6103a636600461246d565b611088565b6102ad6103b936600461246d565b6110e9565b6103d16103cc366004612547565b6112af565b6040516102d5969594939291906125a9565b600b546103039060ff1681565b6102cb61131f565b6102cb60045481565b6102cb60025481565b6102ad611336565b6104397f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102d5565b6102ad61134a565b6102ad611512565b6102cb60085481565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6102cb60065481565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6104d46104cf3660046125f5565b6115ef565b6040516102d59190612610565b6102cb6201518081565b6000546001600160a01b0316610439565b6102cb6116e8565b6102cb6116f9565b6104397f000000000000000000000000000000000000000000000000000000000000000081565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6102cb60055481565b600b546103039062010000900460ff1681565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6102cb60075481565b6102cb60015481565b6102cb7f000000000000000000000000000000000000000000000000000000000000000081565b6102cb670de0b6b3a764000081565b6102ad6105f336600461246d565b611712565b610600611777565b604080519283526020830191909152016102d5565b61038b6117f7565b6102cb60095481565b6102ad61063436600461246d565b6118ed565b6102ad6106473660046125f5565b6118fa565b600b5460ff161561067057604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156106995760405163eebee04f60e01b815260040160405180910390fd5b6106a1611970565b6106aa81611980565b50565b6106b5611b03565b600b54610100900460ff16156106de5760405163e6c1c8bf60e01b815260040160405180910390fd5b600b805461010062ffff00199091166201000084151502171790556040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078491906126ac565b905081156107f157610794611970565b600042600554116107a65760006107c1565b600854426005546107b791906126db565b6107c191906126f4565b90506000816001546008546107d691906126f4565b6107e091906126db565b90506107ec81846126db565b925050505b60405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561085e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108829190612713565b506040805133815283151560208201527f156a2b3940a4c3c2a905ee35163815d4146391134c92d0b6b53f33afe993f718910160405180910390a15050565b600b5460ff16156108e557604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff161561090e5760405163eebee04f60e01b815260040160405180910390fd5b610916611970565b81600003610937576040516344c7244760e11b815260040160405180910390fd5b60045482101561096a5760048054604051630b30907560e01b815291820184905260248201526044015b60405180910390fd5b60065415801561097c57506000600354115b1561099e5761098c600354611b5d565b6000600355610999611970565b6109c1565b6005544211156109c157604051636e6b983360e01b815260040160405180910390fd5b60006109cc82611bbc565b5090506000670de0b6b3a76400006109e483866126f4565b6109ee9190612730565b6109f89085612752565b9050600c6000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060c00160405280866001600160701b03168152602001836001600160701b03168152602001600063ffffffff1681526020016009546001600160701b0316815260200160006001600160701b03168152602001856002811115610a8857610a88612571565b905281546001808201845560009384526020938490208351600293840290910180549585015160408601516001600160701b039384166001600160e01b031998891617600160701b9285168302176001600160e01b0316600160e01b63ffffffff909216820217835560608701519483018054608089015196861699169890981794909316029290921780865560a0850151949592949360ff60e01b1990911691908490811115610b3b57610b3b612571565b021790555050508360066000828254610b549190612752565b925050819055508060076000828254610b6d9190612752565b90915550610ba890506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333087611d15565b336000818152600c60205260409020547f5af417134f72a9d41143ace85b0a26dce6f550f894f2cbc1eeee8810603d91b690610be6906001906126db565b60408051918252602082018890520160405180910390a250505050565b600b5460ff1615610c2757604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610c505760405163eebee04f60e01b815260040160405180910390fd5b610c58611970565b336000908152600c60205260408120905b8154811015610cdf576000828281548110610c8657610c86612765565b6000918252602090912060029091020180549091506001600160701b031615801590610cbe57508054600160e01b900463ffffffff16155b15610ccc57610ccc82611d9f565b5080610cd78161277b565b915050610c69565b5050565b610ceb611b03565b600b805460ff1916911515919091179055565b600b5460ff1615610d2257604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610d4b5760405163eebee04f60e01b815260040160405180910390fd5b610d53611970565b6106aa81611d9f565b600b54610100900460ff16610d8457604051630809727360e01b815260040160405180910390fd5b600b5462010000900460ff16610dad576040516399f0c45d60e01b815260040160405180910390fd5b336000908152600c60205260408120815b8154811015610e4157610dd13382611f2d565b6000828281548110610de557610de5612765565b600091825260209091206002909102016001810154909150610e1790600160701b90046001600160701b031685612752565b60019091018054600160701b600160e01b0319169055925080610e398161277b565b915050610dbe565b508115610cdf57610e7c6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338461208e565b60405182815233907f07181ceaa5c61f1818da3a082bd8f1f5a85817f2f0ff49e19e3b6a8b30822f559060200160405180910390a25050565b600b5460009060ff1615610edc57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610f055760405163eebee04f60e01b815260040160405180910390fd5b610f0d611970565b610f168261210c565b90505b919050565b600b5460609060ff1615610f4557604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610f6e5760405163eebee04f60e01b815260040160405180910390fd5b610f76611970565b336000908152600c60205260408120805490919067ffffffffffffffff811115610fa257610fa2612794565b604051908082528060200260200182016040528015610fcb578160200160208202803683370190505b50905060005b8254811015611081576000838281548110610fee57610fee612765565b6000918252602090912060029091020180549091506001600160701b03161580159061102757508054600160e01b900463ffffffff1615155b801561104157508054600160e01b900463ffffffff164210155b1561106e5761104f8261210c565b83838151811061106157611061612765565b6020026020010181815250505b50806110798161277b565b915050610fd1565b5091505090565b600b5460009060ff16156110af57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156110d85760405163eebee04f60e01b815260040160405180910390fd5b6110e0611970565b610f16826122e1565b6110f1611b03565b6110f9611970565b6005544210156111365760004260055461111391906126db565b905060006008548261112591906126f4565b90506111318184612752565b925050505b6002548110156111595760405163c2bdb92560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156111c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e491906126ac565b90506000600354836111f69190612752565b90508082101561122357604051635e6e7a3760e01b81526004810183905260248101829052604401610961565b6000600254846112339190612730565b60025490915061124d670de0b6b3a7640000600019612730565b6112579190612730565b8110611275576040516207703f60e81b815260040160405180910390fd5b60065460000361129c5783600360008282546112919190612752565b909155506112a59050565b6112a584611b5d565b505042600a555050565b600c60205281600052604060002081815481106112cb57600080fd5b6000918252602090912060029091020180546001909101546001600160701b038083169450600160701b8084048216945063ffffffff600160e01b948590041693838316939182049092169160ff91041686565b60006005544210611331575060055490565b504290565b61133e611b03565b61134860006123c7565b565b600b54610100900460ff1661137257604051630809727360e01b815260040160405180910390fd5b336000908152600c60205260408120905b8154811015610cdf57600b5462010000900460ff16156113a7576113a73382611f2d565b60008282815481106113bb576113bb612765565b6000918252602090912060029091020180549091506001600160701b031680156114fd5780600660008282546113f191906126db565b9091555050815460078054600160701b9092046001600160701b03169160009061141c9084906126db565b909155505081546001600160e01b031916825560405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561149c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c09190612713565b50604080518481526020810183905233917f4c363bde70ba6f3710164df779019cbdf717067dd1c615ccc164601c05168a36910160405180910390a25b5050808061150a9061277b565b915050611383565b600b5460ff161561153657604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff161561155f5760405163eebee04f60e01b815260040160405180910390fd5b611567611970565b336000908152600c60205260408120905b8154811015610cdf57600082828154811061159557611595612765565b6000918252602090912060029091020180549091506001600160701b0316158015906115ce57508054600160e01b900463ffffffff1615155b156115dc576115dc82611980565b50806115e78161277b565b915050611578565b6001600160a01b0381166000908152600c60209081526040808320805482518185028101850190935280835260609492939192909184015b828210156116dd5760008481526020908190206040805160c081018252600286810290930180546001600160701b038082168452600160701b808304821697850197909752600160e01b9182900463ffffffff16948401949094526001820154808516606085015295860490931660808301529093909260a085019290910460ff16908111156116b9576116b9612571565b60028111156116ca576116ca612571565b8152505081526020019060010190611627565b505050509050919050565b6116f66201518060076126f4565b81565b6117076201518060076126f4565b6116f69060026126f4565b61171a611b03565b6003541561173b5760405163116eb83560e11b815260040160405180910390fd5b60028190556040518181527f66b9213ecbabaff7979ad49112aa2a6835a4ad4307c6d562d1af7529d9efa523906020015b60405180910390a150565b60008061178261131f565b90506006546000036117975760095491509091565b6000600a54826117a791906126db565b90506000600854826117b991906126f4565b90506000600754670de0b6b3a7640000836117d491906126f4565b6117de9190612730565b9050806009546117ee9190612752565b94505050509091565b600b5460609060ff161561181e57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156118475760405163eebee04f60e01b815260040160405180910390fd5b61184f611970565b336000908152600c60205260409020805467ffffffffffffffff81111561187857611878612794565b6040519080825280602002602001820160405280156118a1578160200160208202803683370190505b50915060005b81548110156118e8576118b9816122e1565b8382815181106118cb576118cb612765565b6020908102919091010152806118e08161277b565b9150506118a7565b505090565b6118f5611b03565b600455565b611902611b03565b6001600160a01b0381166119675760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610961565b6106aa816123c7565b611978611777565b600a55600955565b336000908152600c602052604081208054839081106119a1576119a1612765565b60009182526020822060029091020180549092506001600160701b0316908190036119e25760405163102c472960e11b815260048101849052602401610961565b8154600160e01b900463ffffffff16600003611a1457604051631211d1cb60e31b815260048101849052602401610961565b611a1e3384611f2d565b6001820154600090611a3990600160e01b900460ff16611bbc565b508354909150600090670de0b6b3a764000090611a609084906001600160701b03166126f4565b611a6a9190612730565b8454909150600090611a869083906001600160701b0316612752565b85546001600160e01b036001600160701b03808416600160701b02919091169116178655600780549192508391600090611ac1908490612752565b909155505060405186815233907fe13d5cf5271bd721532059c5883b639ba871a2b135c24caf452a8de615213fd49060200160405180910390a2505050505050565b6000546001600160a01b031633146113485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610961565b600254611b6a9082612730565b600855600254611b7a9042612752565b60058190556002546001556040805183815260208101929092527fff92011f5b6637357c4904d41ea3f9d759723fe605d64ac0e2c47541d288dc03910161176c565b60008080836002811115611bd257611bd2612571565b03611c2157507f0000000000000000000000000000000000000000000000000000000000000000927f000000000000000000000000000000000000000000000000000000000000000092509050565b6001836002811115611c3557611c35612571565b03611c8457507f0000000000000000000000000000000000000000000000000000000000000000927f000000000000000000000000000000000000000000000000000000000000000092509050565b6002836002811115611c9857611c98612571565b03611ce757507f0000000000000000000000000000000000000000000000000000000000000000927f000000000000000000000000000000000000000000000000000000000000000092509050565b826002811115611cf957611cf9612571565b60405163208a64e760e11b815260040161096191815260200190565b60006040516323b872dd60e01b81528460048201528360248201528260448201526020600060648360008a5af13d15601f3d1160016000511416171691505080611d985760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b6044820152606401610961565b5050505050565b336000908152600c60205260408120805483908110611dc057611dc0612765565b60009182526020822060029091020180549092506001600160701b031690819003611e015760405163102c472960e11b815260048101849052602401610961565b8154600160e01b900463ffffffff1615611e3157604051630c7820cd60e31b815260048101849052602401610961565b611e3b3384611f2d565b8154600090611e5b908390600160701b90046001600160701b03166126db565b90506000611e7984600101601c9054906101000a900460ff16611bbc565b8554600160701b600160e01b031916600160701b6001600160701b038716021786559150611ea990508142612752565b845463ffffffff91909116600160e01b026001600160e01b03909116178455600780546001600160701b0384169190600090611ee69084906126db565b9091555050604080518681526020810185905233917f7659747cd8571f1071eea946fdc648adcf181cad916f32a05f82c3a525976048910160405180910390a25050505050565b6001600160a01b0382166000908152600c60205260408120805483908110611f5757611f57612765565b60009182526020822060029091020180549092506001600160701b03169003611f7f57505050565b6040805160c08101825282546001600160701b038082168352600160701b8083048216602085015263ffffffff600160e01b938490041694840194909452600185015480821660608501529384041660808301526000926120119291859160a084019160ff9104166002811115611ff857611ff8612571565b600281111561200957612009612571565b905250612417565b90508082600101600e8282829054906101000a90046001600160701b031661203991906127aa565b92506101000a8154816001600160701b0302191690836001600160701b031602179055506009548260010160006101000a8154816001600160701b0302191690836001600160701b0316021790555050505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806121065760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610961565b50505050565b336000908152600c6020526040812080548291908490811061213057612130612765565b60009182526020822060029091020180549092506001600160701b0316908190036121715760405163102c472960e11b815260048101859052602401610961565b8154600160e01b900463ffffffff16158061219957508154600160e01b900463ffffffff1642105b156121ba57604051633a49774d60e11b815260048101859052602401610961565b6121c43385611f2d565b60018201805483546001600160e01b0319168455600160701b600160e01b0319811690915560068054600160701b9092046001600160701b0316945082916000906122109084906126db565b92505081905550806007600082825461222991906126db565b9091555061226390506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338361208e565b6122976001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338561208e565b604080518581526020810183905290810184905233907ffbd65cfd6de1493db337385c0712095397ecbd0504df64b861cdfceb80c7b4229060600160405180910390a25050919050565b336000908152600c6020526040812080548291908490811061230557612305612765565b9060005260206000209060020201905061231f3384611f2d565b6001810154600160701b90046001600160701b0316915081156123c157600181018054600160701b600160e01b03191690556123856001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338461208e565b604080518481526020810184905233917f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7910160405180910390a25b50919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008082606001516001600160701b031660095461243591906126db565b90506000670de0b6b3a76400008285602001516001600160701b031661245b91906126f4565b6124659190612730565b949350505050565b60006020828403121561247f57600080fd5b5035919050565b80151581146106aa57600080fd5b6000602082840312156124a657600080fd5b81356124b181612486565b9392505050565b600080604083850312156124cb57600080fd5b823591506020830135600381106124e157600080fd5b809150509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561252457835183529284019291840191600101612508565b50909695505050505050565b80356001600160a01b0381168114610f1957600080fd5b6000806040838503121561255a57600080fd5b61256383612530565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b600381106125a557634e487b7160e01b600052602160045260246000fd5b9052565b6001600160701b038781168252868116602083015263ffffffff8616604083015284811660608301528316608082015260c081016125ea60a0830184612587565b979650505050505050565b60006020828403121561260757600080fd5b6124b182612530565b602080825282518282018190526000919060409081850190868401855b8281101561269f57815180516001600160701b039081168652878201518116888701528682015163ffffffff16878701526060808301518216908701526080808301519091169086015260a0908101519061268a81870183612587565b505060c093909301929085019060010161262d565b5091979650505050505050565b6000602082840312156126be57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156126ee576126ee6126c5565b92915050565b600081600019048311821515161561270e5761270e6126c5565b500290565b60006020828403121561272557600080fd5b81516124b181612486565b60008261274d57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156126ee576126ee6126c5565b634e487b7160e01b600052603260045260246000fd5b60006001820161278d5761278d6126c5565b5060010190565b634e487b7160e01b600052604160045260246000fd5b6001600160701b038181168382160190808211156127ca576127ca6126c5565b509291505056fea26469706673582212205d043f301312a590bbf59b732239d149793d32ffc53b0ddfdc8a8328e655fcae64736f6c634300081000330000000000000000000000007340d1fecd4b64a4ac34f826b21c945d44d7407f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e6000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd10000000000000000000000000000000000000000000000000000000000278d00000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000429d069189e000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000006978000000000000000000000000000000000000000000000000000000000000d2f000000000000000000000000000000000000000000000000000000000000127500
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102955760003560e01c80637b0a47ee11610167578063af38d757116100ce578063cc1a378f11610087578063cc1a378f146105e5578063cd3daf9d146105f8578063d1058e5914610615578063df136d651461061d578063e78ec42e14610626578063f2fde38b1461063957600080fd5b8063af38d75714610563578063b5bc32bd14610576578063b98fe9471461059d578063baaa17f2146105a6578063bdb16286146105af578063c2ee3a08146105d657600080fd5b80638da5cb5b116101205780638da5cb5b146104eb5780638e6f6b77146104fc578063934d1fa4146105045780639d1390621461050c578063a827710014610533578063a85adeab1461055a57600080fd5b80637b0a47ee146104615780637bafd02d1461046a5780637d882097146104915780638220155b1461049a578063842e2981146104c1578063863e76db146104e157600080fd5b806335322f371161020b578063636bfbab116101c4578063636bfbab146103f8578063657bab8814610401578063715018a61461040a57806372f702f3146104125780637589cf2f14610451578063785f51801461045957600080fd5b806335322f3714610383578063379607f5146103985780633c6b16ab146103ab578063584b62a1146103be5780635c975abb146103e35780635ef73e24146103f057600080fd5b806315f7b4021161025d57806315f7b4021461031357806316c38b3c1461031b578063190ad7631461032e57806327de9e32146103555780632b8278ca146103685780632e17de781461037057600080fd5b80630a72f2ea1461029a5780630ac62e02146102af5780630d06e528146102c257806310087fb1146102de57806312fa6feb146102f1575b600080fd5b6102ad6102a836600461246d565b61064c565b005b6102ad6102bd366004612494565b6106ad565b6102cb60035481565b6040519081526020015b60405180910390f35b6102ad6102ec3660046124b8565b6108c1565b600b5461030390610100900460ff1681565b60405190151581526020016102d5565b6102ad610c03565b6102ad610329366004612494565b610ce3565b6102cb7f0000000000000000000000000000000000000000000000000429d069189e000081565b6102ad61036336600461246d565b610cfe565b6102ad610d5c565b6102cb61037e36600461246d565b610eb5565b61038b610f1e565b6040516102d591906124ec565b6102cb6103a636600461246d565b611088565b6102ad6103b936600461246d565b6110e9565b6103d16103cc366004612547565b6112af565b6040516102d5969594939291906125a9565b600b546103039060ff1681565b6102cb61131f565b6102cb60045481565b6102cb60025481565b6102ad611336565b6104397f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e681565b6040516001600160a01b0390911681526020016102d5565b6102ad61134a565b6102ad611512565b6102cb60085481565b6102cb7f00000000000000000000000000000000000000000000000006f05b59d3b2000081565b6102cb60065481565b6102cb7f00000000000000000000000000000000000000000000000000000000000d2f0081565b6104d46104cf3660046125f5565b6115ef565b6040516102d59190612610565b6102cb6201518081565b6000546001600160a01b0316610439565b6102cb6116e8565b6102cb6116f9565b6104397f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd181565b6102cb7f000000000000000000000000000000000000000000000000000000000012750081565b6102cb60055481565b600b546103039062010000900460ff1681565b6102cb7f000000000000000000000000000000000000000000000000000000000006978081565b6102cb60075481565b6102cb60015481565b6102cb7f000000000000000000000000000000000000000000000000016345785d8a000081565b6102cb670de0b6b3a764000081565b6102ad6105f336600461246d565b611712565b610600611777565b604080519283526020830191909152016102d5565b61038b6117f7565b6102cb60095481565b6102ad61063436600461246d565b6118ed565b6102ad6106473660046125f5565b6118fa565b600b5460ff161561067057604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156106995760405163eebee04f60e01b815260040160405180910390fd5b6106a1611970565b6106aa81611980565b50565b6106b5611b03565b600b54610100900460ff16156106de5760405163e6c1c8bf60e01b815260040160405180910390fd5b600b805461010062ffff00199091166201000084151502171790556040516370a0823160e01b81523060048201526000907f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd16001600160a01b0316906370a0823190602401602060405180830381865afa158015610760573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078491906126ac565b905081156107f157610794611970565b600042600554116107a65760006107c1565b600854426005546107b791906126db565b6107c191906126f4565b90506000816001546008546107d691906126f4565b6107e091906126db565b90506107ec81846126db565b925050505b60405163a9059cbb60e01b8152336004820152602481018290527f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd16001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561085e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108829190612713565b506040805133815283151560208201527f156a2b3940a4c3c2a905ee35163815d4146391134c92d0b6b53f33afe993f718910160405180910390a15050565b600b5460ff16156108e557604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff161561090e5760405163eebee04f60e01b815260040160405180910390fd5b610916611970565b81600003610937576040516344c7244760e11b815260040160405180910390fd5b60045482101561096a5760048054604051630b30907560e01b815291820184905260248201526044015b60405180910390fd5b60065415801561097c57506000600354115b1561099e5761098c600354611b5d565b6000600355610999611970565b6109c1565b6005544211156109c157604051636e6b983360e01b815260040160405180910390fd5b60006109cc82611bbc565b5090506000670de0b6b3a76400006109e483866126f4565b6109ee9190612730565b6109f89085612752565b9050600c6000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060c00160405280866001600160701b03168152602001836001600160701b03168152602001600063ffffffff1681526020016009546001600160701b0316815260200160006001600160701b03168152602001856002811115610a8857610a88612571565b905281546001808201845560009384526020938490208351600293840290910180549585015160408601516001600160701b039384166001600160e01b031998891617600160701b9285168302176001600160e01b0316600160e01b63ffffffff909216820217835560608701519483018054608089015196861699169890981794909316029290921780865560a0850151949592949360ff60e01b1990911691908490811115610b3b57610b3b612571565b021790555050508360066000828254610b549190612752565b925050819055508060076000828254610b6d9190612752565b90915550610ba890506001600160a01b037f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e616333087611d15565b336000818152600c60205260409020547f5af417134f72a9d41143ace85b0a26dce6f550f894f2cbc1eeee8810603d91b690610be6906001906126db565b60408051918252602082018890520160405180910390a250505050565b600b5460ff1615610c2757604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610c505760405163eebee04f60e01b815260040160405180910390fd5b610c58611970565b336000908152600c60205260408120905b8154811015610cdf576000828281548110610c8657610c86612765565b6000918252602090912060029091020180549091506001600160701b031615801590610cbe57508054600160e01b900463ffffffff16155b15610ccc57610ccc82611d9f565b5080610cd78161277b565b915050610c69565b5050565b610ceb611b03565b600b805460ff1916911515919091179055565b600b5460ff1615610d2257604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610d4b5760405163eebee04f60e01b815260040160405180910390fd5b610d53611970565b6106aa81611d9f565b600b54610100900460ff16610d8457604051630809727360e01b815260040160405180910390fd5b600b5462010000900460ff16610dad576040516399f0c45d60e01b815260040160405180910390fd5b336000908152600c60205260408120815b8154811015610e4157610dd13382611f2d565b6000828281548110610de557610de5612765565b600091825260209091206002909102016001810154909150610e1790600160701b90046001600160701b031685612752565b60019091018054600160701b600160e01b0319169055925080610e398161277b565b915050610dbe565b508115610cdf57610e7c6001600160a01b037f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd116338461208e565b60405182815233907f07181ceaa5c61f1818da3a082bd8f1f5a85817f2f0ff49e19e3b6a8b30822f559060200160405180910390a25050565b600b5460009060ff1615610edc57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610f055760405163eebee04f60e01b815260040160405180910390fd5b610f0d611970565b610f168261210c565b90505b919050565b600b5460609060ff1615610f4557604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff1615610f6e5760405163eebee04f60e01b815260040160405180910390fd5b610f76611970565b336000908152600c60205260408120805490919067ffffffffffffffff811115610fa257610fa2612794565b604051908082528060200260200182016040528015610fcb578160200160208202803683370190505b50905060005b8254811015611081576000838281548110610fee57610fee612765565b6000918252602090912060029091020180549091506001600160701b03161580159061102757508054600160e01b900463ffffffff1615155b801561104157508054600160e01b900463ffffffff164210155b1561106e5761104f8261210c565b83838151811061106157611061612765565b6020026020010181815250505b50806110798161277b565b915050610fd1565b5091505090565b600b5460009060ff16156110af57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156110d85760405163eebee04f60e01b815260040160405180910390fd5b6110e0611970565b610f16826122e1565b6110f1611b03565b6110f9611970565b6005544210156111365760004260055461111391906126db565b905060006008548261112591906126f4565b90506111318184612752565b925050505b6002548110156111595760405163c2bdb92560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000907f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd16001600160a01b0316906370a0823190602401602060405180830381865afa1580156111c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e491906126ac565b90506000600354836111f69190612752565b90508082101561122357604051635e6e7a3760e01b81526004810183905260248101829052604401610961565b6000600254846112339190612730565b60025490915061124d670de0b6b3a7640000600019612730565b6112579190612730565b8110611275576040516207703f60e81b815260040160405180910390fd5b60065460000361129c5783600360008282546112919190612752565b909155506112a59050565b6112a584611b5d565b505042600a555050565b600c60205281600052604060002081815481106112cb57600080fd5b6000918252602090912060029091020180546001909101546001600160701b038083169450600160701b8084048216945063ffffffff600160e01b948590041693838316939182049092169160ff91041686565b60006005544210611331575060055490565b504290565b61133e611b03565b61134860006123c7565b565b600b54610100900460ff1661137257604051630809727360e01b815260040160405180910390fd5b336000908152600c60205260408120905b8154811015610cdf57600b5462010000900460ff16156113a7576113a73382611f2d565b60008282815481106113bb576113bb612765565b6000918252602090912060029091020180549091506001600160701b031680156114fd5780600660008282546113f191906126db565b9091555050815460078054600160701b9092046001600160701b03169160009061141c9084906126db565b909155505081546001600160e01b031916825560405163a9059cbb60e01b8152336004820152602481018290527f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e66001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561149c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c09190612713565b50604080518481526020810183905233917f4c363bde70ba6f3710164df779019cbdf717067dd1c615ccc164601c05168a36910160405180910390a25b5050808061150a9061277b565b915050611383565b600b5460ff161561153657604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff161561155f5760405163eebee04f60e01b815260040160405180910390fd5b611567611970565b336000908152600c60205260408120905b8154811015610cdf57600082828154811061159557611595612765565b6000918252602090912060029091020180549091506001600160701b0316158015906115ce57508054600160e01b900463ffffffff1615155b156115dc576115dc82611980565b50806115e78161277b565b915050611578565b6001600160a01b0381166000908152600c60209081526040808320805482518185028101850190935280835260609492939192909184015b828210156116dd5760008481526020908190206040805160c081018252600286810290930180546001600160701b038082168452600160701b808304821697850197909752600160e01b9182900463ffffffff16948401949094526001820154808516606085015295860490931660808301529093909260a085019290910460ff16908111156116b9576116b9612571565b60028111156116ca576116ca612571565b8152505081526020019060010190611627565b505050509050919050565b6116f66201518060076126f4565b81565b6117076201518060076126f4565b6116f69060026126f4565b61171a611b03565b6003541561173b5760405163116eb83560e11b815260040160405180910390fd5b60028190556040518181527f66b9213ecbabaff7979ad49112aa2a6835a4ad4307c6d562d1af7529d9efa523906020015b60405180910390a150565b60008061178261131f565b90506006546000036117975760095491509091565b6000600a54826117a791906126db565b90506000600854826117b991906126f4565b90506000600754670de0b6b3a7640000836117d491906126f4565b6117de9190612730565b9050806009546117ee9190612752565b94505050509091565b600b5460609060ff161561181e57604051630d6819e560e11b815260040160405180910390fd5b600b54610100900460ff16156118475760405163eebee04f60e01b815260040160405180910390fd5b61184f611970565b336000908152600c60205260409020805467ffffffffffffffff81111561187857611878612794565b6040519080825280602002602001820160405280156118a1578160200160208202803683370190505b50915060005b81548110156118e8576118b9816122e1565b8382815181106118cb576118cb612765565b6020908102919091010152806118e08161277b565b9150506118a7565b505090565b6118f5611b03565b600455565b611902611b03565b6001600160a01b0381166119675760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610961565b6106aa816123c7565b611978611777565b600a55600955565b336000908152600c602052604081208054839081106119a1576119a1612765565b60009182526020822060029091020180549092506001600160701b0316908190036119e25760405163102c472960e11b815260048101849052602401610961565b8154600160e01b900463ffffffff16600003611a1457604051631211d1cb60e31b815260048101849052602401610961565b611a1e3384611f2d565b6001820154600090611a3990600160e01b900460ff16611bbc565b508354909150600090670de0b6b3a764000090611a609084906001600160701b03166126f4565b611a6a9190612730565b8454909150600090611a869083906001600160701b0316612752565b85546001600160e01b036001600160701b03808416600160701b02919091169116178655600780549192508391600090611ac1908490612752565b909155505060405186815233907fe13d5cf5271bd721532059c5883b639ba871a2b135c24caf452a8de615213fd49060200160405180910390a2505050505050565b6000546001600160a01b031633146113485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610961565b600254611b6a9082612730565b600855600254611b7a9042612752565b60058190556002546001556040805183815260208101929092527fff92011f5b6637357c4904d41ea3f9d759723fe605d64ac0e2c47541d288dc03910161176c565b60008080836002811115611bd257611bd2612571565b03611c2157507f000000000000000000000000000000000000000000000000016345785d8a0000927f000000000000000000000000000000000000000000000000000000000006978092509050565b6001836002811115611c3557611c35612571565b03611c8457507f0000000000000000000000000000000000000000000000000429d069189e0000927f00000000000000000000000000000000000000000000000000000000000d2f0092509050565b6002836002811115611c9857611c98612571565b03611ce757507f00000000000000000000000000000000000000000000000006f05b59d3b20000927f000000000000000000000000000000000000000000000000000000000012750092509050565b826002811115611cf957611cf9612571565b60405163208a64e760e11b815260040161096191815260200190565b60006040516323b872dd60e01b81528460048201528360248201528260448201526020600060648360008a5af13d15601f3d1160016000511416171691505080611d985760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b6044820152606401610961565b5050505050565b336000908152600c60205260408120805483908110611dc057611dc0612765565b60009182526020822060029091020180549092506001600160701b031690819003611e015760405163102c472960e11b815260048101849052602401610961565b8154600160e01b900463ffffffff1615611e3157604051630c7820cd60e31b815260048101849052602401610961565b611e3b3384611f2d565b8154600090611e5b908390600160701b90046001600160701b03166126db565b90506000611e7984600101601c9054906101000a900460ff16611bbc565b8554600160701b600160e01b031916600160701b6001600160701b038716021786559150611ea990508142612752565b845463ffffffff91909116600160e01b026001600160e01b03909116178455600780546001600160701b0384169190600090611ee69084906126db565b9091555050604080518681526020810185905233917f7659747cd8571f1071eea946fdc648adcf181cad916f32a05f82c3a525976048910160405180910390a25050505050565b6001600160a01b0382166000908152600c60205260408120805483908110611f5757611f57612765565b60009182526020822060029091020180549092506001600160701b03169003611f7f57505050565b6040805160c08101825282546001600160701b038082168352600160701b8083048216602085015263ffffffff600160e01b938490041694840194909452600185015480821660608501529384041660808301526000926120119291859160a084019160ff9104166002811115611ff857611ff8612571565b600281111561200957612009612571565b905250612417565b90508082600101600e8282829054906101000a90046001600160701b031661203991906127aa565b92506101000a8154816001600160701b0302191690836001600160701b031602179055506009548260010160006101000a8154816001600160701b0302191690836001600160701b0316021790555050505050565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806121065760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610961565b50505050565b336000908152600c6020526040812080548291908490811061213057612130612765565b60009182526020822060029091020180549092506001600160701b0316908190036121715760405163102c472960e11b815260048101859052602401610961565b8154600160e01b900463ffffffff16158061219957508154600160e01b900463ffffffff1642105b156121ba57604051633a49774d60e11b815260048101859052602401610961565b6121c43385611f2d565b60018201805483546001600160e01b0319168455600160701b600160e01b0319811690915560068054600160701b9092046001600160701b0316945082916000906122109084906126db565b92505081905550806007600082825461222991906126db565b9091555061226390506001600160a01b037f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e616338361208e565b6122976001600160a01b037f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd116338561208e565b604080518581526020810183905290810184905233907ffbd65cfd6de1493db337385c0712095397ecbd0504df64b861cdfceb80c7b4229060600160405180910390a25050919050565b336000908152600c6020526040812080548291908490811061230557612305612765565b9060005260206000209060020201905061231f3384611f2d565b6001810154600160701b90046001600160701b0316915081156123c157600181018054600160701b600160e01b03191690556123856001600160a01b037f000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd116338461208e565b604080518481526020810184905233917f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7910160405180910390a25b50919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008082606001516001600160701b031660095461243591906126db565b90506000670de0b6b3a76400008285602001516001600160701b031661245b91906126f4565b6124659190612730565b949350505050565b60006020828403121561247f57600080fd5b5035919050565b80151581146106aa57600080fd5b6000602082840312156124a657600080fd5b81356124b181612486565b9392505050565b600080604083850312156124cb57600080fd5b823591506020830135600381106124e157600080fd5b809150509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561252457835183529284019291840191600101612508565b50909695505050505050565b80356001600160a01b0381168114610f1957600080fd5b6000806040838503121561255a57600080fd5b61256383612530565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b600381106125a557634e487b7160e01b600052602160045260246000fd5b9052565b6001600160701b038781168252868116602083015263ffffffff8616604083015284811660608301528316608082015260c081016125ea60a0830184612587565b979650505050505050565b60006020828403121561260757600080fd5b6124b182612530565b602080825282518282018190526000919060409081850190868401855b8281101561269f57815180516001600160701b039081168652878201518116888701528682015163ffffffff16878701526060808301518216908701526080808301519091169086015260a0908101519061268a81870183612587565b505060c093909301929085019060010161262d565b5091979650505050505050565b6000602082840312156126be57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156126ee576126ee6126c5565b92915050565b600081600019048311821515161561270e5761270e6126c5565b500290565b60006020828403121561272557600080fd5b81516124b181612486565b60008261274d57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156126ee576126ee6126c5565b634e487b7160e01b600052603260045260246000fd5b60006001820161278d5761278d6126c5565b5060010190565b634e487b7160e01b600052604160045260246000fd5b6001600160701b038181168382160190808211156127ca576127ca6126c5565b509291505056fea26469706673582212205d043f301312a590bbf59b732239d149793d32ffc53b0ddfdc8a8328e655fcae64736f6c63430008100033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000007340d1fecd4b64a4ac34f826b21c945d44d7407f000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e6000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd10000000000000000000000000000000000000000000000000000000000278d00000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000429d069189e000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000006978000000000000000000000000000000000000000000000000000000000000d2f000000000000000000000000000000000000000000000000000000000000127500
-----Decoded View---------------
Arg [0] : _owner (address): 0x7340D1FeCD4B64A4ac34f826B21c945d44d7407F
Arg [1] : _stakingToken (address): 0xDBe19d1c3F21b1bB250ca7BDaE0687A97B5f77e6
Arg [2] : _distributionToken (address): 0xa670d7237398238DE01267472C6f13e5B8010FD1
Arg [3] : _epochDuration (uint256): 2592000
Arg [4] : shortBoost (uint256): 100000000000000000
Arg [5] : mediumBoost (uint256): 300000000000000000
Arg [6] : longBoost (uint256): 500000000000000000
Arg [7] : shortBoostTime (uint256): 432000
Arg [8] : mediumBoostTime (uint256): 864000
Arg [9] : longBoostTime (uint256): 1209600
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 0000000000000000000000007340d1fecd4b64a4ac34f826b21c945d44d7407f
Arg [1] : 000000000000000000000000dbe19d1c3f21b1bb250ca7bdae0687a97b5f77e6
Arg [2] : 000000000000000000000000a670d7237398238de01267472c6f13e5b8010fd1
Arg [3] : 0000000000000000000000000000000000000000000000000000000000278d00
Arg [4] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [5] : 0000000000000000000000000000000000000000000000000429d069189e0000
Arg [6] : 00000000000000000000000000000000000000000000000006f05b59d3b20000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000069780
Arg [8] : 00000000000000000000000000000000000000000000000000000000000d2f00
Arg [9] : 0000000000000000000000000000000000000000000000000000000000127500
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.12
Net Worth in ETH
0.000052
Token Allocations
SOMM
100.00%
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 100.00% | $0.000498 | 237.8629 | $0.1184 |
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.