Address Contract Verified
Address
0x102f9072bec9Fea359aE687a84B5f4bd33182a33
Balance
0 ETH
Nonce
1
Code Size
6096 bytes
Creator
0x31C75F27...c1a1 at tx 0x13270385...e03bca
Indexed Transactions
0
Contract Bytecode
6096 bytes
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806394db059511610104578063d3cd1c7c116100a2578063ef7ec38711610071578063ef7ec3871461038d578063f0d9247e14610396578063f2fde38b146103a9578063f51ace70146103bc57600080fd5b8063d3cd1c7c14610355578063d9132b2214610368578063dc9126ca14610371578063df136d651461038457600080fd5b8063b8017874116100de578063b80178741461030b578063c241267614610313578063c7b8981c1461033a578063cb82cc8f1461034257600080fd5b806394db0595146102f0578063b0e31b2d146102f9578063b4e55fc61461030257600080fd5b8063640393d31161017c5780638da5cb5b1161014b5780638da5cb5b1461025b5780638df4cf2e146102805780639168ae721461028857806393329f86146102dd57600080fd5b8063640393d31461023a578063715018a61461024257806378922c8f1461024a5780637c777ec91461025357600080fd5b80632df0b5e8116101b85780632df0b5e8146102195780633f3d977a1461022257806362fce4c41461022a578063639793fa1461023257600080fd5b80630976769d146101df57806309f6ae14146101fb5780631b65cd6314610210575b600080fd5b6101e860035481565b6040519081526020015b60405180910390f35b61020e610209366004611686565b6103c5565b005b6101e860075481565b6101e8600c5481565b61020e61046f565b61020e6105c2565b6101e86107f2565b6101e8610858565b61020e6108ff565b6101e860085481565b6101e8610913565b6001546001600160a01b03165b6040516001600160a01b0390911681526020016101f2565b61020e61098f565b6102bd61029636600461169f565b600d6020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016101f2565b6101e86102eb36600461169f565b610d3a565b6101e8600b5481565b6101e860025481565b6101e8600a5481565b6101e8610d98565b6102687f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee81565b61020e610daf565b61020e610350366004611686565b61102b565b6101e861036336600461169f565b61134d565b6101e860095481565b61020e61037f366004611686565b6113be565b6101e860065481565b6101e860055481565b61020e6103a4366004611686565b611504565b61020e6103b736600461169f565b6115a2565b6101e860045481565b6103cd6115dd565b60c88111156104335760405162461bcd60e51b815260206004820152602760248201527f556e7374616b652066656520657863656564732032252c206d6178696d756d20604482015266185b1b1bddd95960ca1b60648201526084015b60405180910390fd5b60088190556040518181527fe718b78d7b4446604944eca0ff374177fe5e74c67f04441877baeb3d412c99c8906020015b60405180910390a150565b336104786107f2565b600655610483610913565b600c5561048e610d98565b6005556001600160a01b0381166000908152600d6020526040812060038101549091036104cc576104be8261134d565b600282015560065460018201555b336000908152600d60205260409020805461051c5760405162461bcd60e51b815260206004820152601060248201526f139bc81d1bdad95b9cc81cdd185ad95960821b604482015260640161042a565b60038101541561056e5760405162461bcd60e51b815260206004820152601960248201527f556e7374616b6520616c726561647920696e6974696174656400000000000000604482015260640161042a565b42816003018190555080600001546003600082825461058d91906116de565b909155505060405133907f1519c8ae4064242b3caf78c4eb66acc5055fbe9cd35f28294b5492f6aea9ff6e90600090a2505050565b60006105cc6107f2565b6006556105d7610913565b600c556105e2610d98565b6005556001600160a01b0381166000908152600d602052604081206003810154909103610620576106128261134d565b600282015560065460018201555b6106286115dd565b600a5442116106855760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206265666f726520656d697373696f6e20604482015262195b9960ea1b606482015260840161042a565b600061068f610858565b90506000670de0b6b3a76400006106a4610913565b6106ae919061170d565b90508082116106ff5760405162461bcd60e51b815260206004820152601f60248201527f4e6f2072656d61696e696e6720746f6b656e7320746f20776974686472617700604482015260640161042a565b600061070b82846116de565b60405163a9059cbb60e01b8152336004820152602481018290529091507f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee6001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561077b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079f9190611721565b6107eb5760405162461bcd60e51b815260206004820152601760248201527f546f6b656e207769746864726177616c206661696c6564000000000000000000604482015260640161042a565b5050505050565b6000600354600003610805575060065490565b600354600454600554610816610d98565b61082091906116de565b61082a9190611743565b61083c90670de0b6b3a7640000611743565b610846919061170d565b600654610853919061175a565b905090565b600b546002546040516370a0823160e01b815230600482015260009291906001600160a01b037f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee16906370a0823190602401602060405180830381865afa1580156108c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108eb919061176d565b6108f591906116de565b61085391906116de565b6109076115dd565b610911600061160a565b565b600354600090808203610928575050600c5490565b6000600454600554610938610d98565b61094291906116de565b61094c9190611743565b61095e90670de0b6b3a7640000611743565b9050600061096c8383611786565b90508082600c5461097d919061175a565b61098791906116de565b935050505090565b61099761165c565b336109a06107f2565b6006556109ab610913565b600c556109b6610d98565b6005556001600160a01b0381166000908152600d6020526040812060038101549091036109f4576109e68261134d565b600282015560065460018201555b336000908152600d602052604090208054610a445760405162461bcd60e51b815260206004820152601060248201526f139bc81d1bdad95b9cc81cdd185ad95960821b604482015260640161042a565b6000816003015411610a905760405162461bcd60e51b8152602060048201526015602482015274155b9cdd185ad9481b9bdd081a5b9a5d1a585d1959605a1b604482015260640161042a565b6007548160030154610aa2919061175a565b421015610af15760405162461bcd60e51b815260206004820152601760248201527f54696d656c6f636b206e6f742079657420706173736564000000000000000000604482015260640161042a565b8054600282015460085460009061271090610b0c9085611743565b610b16919061170d565b90506000610b2482856116de565b90506000610b30610858565b905082600b6000828254610b44919061175a565b925050819055508460026000828254610b5d91906116de565b90915550506000808755600187018190556003870155818415801590610b835750848210155b15610c1557610b9a85670de0b6b3a7640000611743565b600c5410610bcb57610bb485670de0b6b3a7640000611743565b600c6000828254610bc591906116de565b90915550505b610bd5858261175a565b6000600289015560405186815290915033907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b60405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee6001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca69190611721565b610cf25760405162461bcd60e51b815260206004820152601760248201527f556e7374616b65207472616e73666572206661696c6564000000000000000000604482015260640161042a565b60405186815233907f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f759060200160405180910390a25050505050505050506109116001600055565b6001600160a01b0381166000908152600d602052604081206007546003820154610d64919061175a565b421015610d8f57426007548260030154610d7e919061175a565b610d8891906116de565b9392505050565b50600092915050565b6000600a544210610daa5750600a5490565b504290565b610db761165c565b33610dc06107f2565b600655610dcb610913565b600c55610dd6610d98565b6005556001600160a01b0381166000908152600d602052604081206003810154909103610e1457610e068261134d565b600282015560065460018201555b336000908152600d60205260409020600281015480610e6b5760405162461bcd60e51b81526020600482015260136024820152724e6f207265776172647320746f20636c61696d60681b604482015260640161042a565b6000610e75610858565b905081811015610ec75760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e742066756e647320666f7220726577617264000000604482015260640161042a565b610ed982670de0b6b3a7640000611743565b600c5410610f0a57610ef382670de0b6b3a7640000611743565b600c6000828254610f0491906116de565b90915550505b6000600284015560405163a9059cbb60e01b8152336004820152602481018390527f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee6001600160a01b03169063a9059cbb906044016020604051808303816000875af1158015610f7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa29190611721565b610fe75760405162461bcd60e51b815260206004820152601660248201527514995dd85c99081d1c985b9cd9995c8819985a5b195960521b604482015260640161042a565b60405182815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505050506109116001600055565b61103361165c565b3361103c6107f2565b600655611047610913565b600c55611052610d98565b6005556001600160a01b0381166000908152600d602052604081206003810154909103611090576110828261134d565b600282015560065460018201555b600083116110d15760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015260640161042a565b6009544210156111235760405162461bcd60e51b815260206004820152601760248201527f5374616b696e67206e6f74207965742073746172746564000000000000000000604482015260640161042a565b600a544211156111755760405162461bcd60e51b815260206004820152601860248201527f5374616b696e6720706572696f642068617320656e6465640000000000000000604482015260640161042a565b336000908152600d602052604090206003810154156111e55760405162461bcd60e51b815260206004820152602660248201527f43616e6e6f74207374616b6520616674657220696e6974696174696e6720756e60448201526539ba30b5b29760d11b606482015260840161042a565b83600260008282546111f7919061175a565b925050819055508360036000828254611210919061175a565b909155505080548490829060009061122990849061175a565b90915550506040516323b872dd60e01b8152336004820152306024820152604481018590527f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee6001600160a01b0316906323b872dd906064016020604051808303816000875af11580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c59190611721565b6113085760405162461bcd60e51b8152602060048201526014602482015273151bdad95b8819195c1bdcda5d0819985a5b195960621b604482015260640161042a565b60405184815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200160405180910390a250505061134a6001600055565b50565b6001600160a01b0381166000908152600d60205260408120600381015415611379576002015492915050565b8060020154670de0b6b3a764000082600101546113946107f2565b61139e91906116de565b83546113aa9190611743565b6113b4919061170d565b610d88919061175a565b6113c66115dd565b600b548111156114185760405162461bcd60e51b815260206004820152601b60248201527f416d6f756e742065786365656473206163637275656420666565730000000000604482015260640161042a565b80600b600082825461142a91906116de565b909155505060405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000042c83a91b3a79de5488cd9280a4df564e13a79ee6001600160a01b03169063a9059cbb906044016020604051808303816000875af115801561149c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c09190611721565b61134a5760405162461bcd60e51b8152602060048201526015602482015274119959481dda5d1a191c985dd85b0819985a5b1959605a1b604482015260640161042a565b61150c6115dd565b6213c68081111561156e5760405162461bcd60e51b815260206004820152602660248201527f54696d65206c6f636b206d757374206265206265747765656e203020746f203160448201526535206461797360d01b606482015260840161042a565b60078190556040518181527e304d9af03082613b46c738ade93be8d8c12d696efb7431d07e51837273c2fa90602001610464565b6115aa6115dd565b6001600160a01b0381166115d457604051631e4fbdf760e01b81526000600482015260240161042a565b61134a8161160a565b6001546001600160a01b031633146109115760405163118cdaa760e01b815233600482015260240161042a565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60026000540361167f57604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b60006020828403121561169857600080fd5b5035919050565b6000602082840312156116b157600080fd5b81356001600160a01b0381168114610d8857600080fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156116f1576116f16116c8565b92915050565b634e487b7160e01b600052601260045260246000fd5b60008261171c5761171c6116f7565b500490565b60006020828403121561173357600080fd5b81518015158114610d8857600080fd5b80820281158282048414176116f1576116f16116c8565b808201808211156116f1576116f16116c8565b60006020828403121561177f57600080fd5b5051919050565b600082611795576117956116f7565b50069056fea2646970667358221220106cc5c05e42f8dd3a47cada4527577d59e20d8c531023fcbb32b2415e99348564736f6c634300081b0033
Verified Source Code Full Match
Compiler: v0.8.27+commit.40a35a09
EVM: paris
Optimization: Yes (200 runs)
Staking.sol 245 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.27;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MiraiStaking is ReentrancyGuard, Ownable {
IERC20 public immutable Token;
uint256 public totalTokensStaked;
uint256 public totalStakedAccruingRewards;
uint256 public currentRewardRate;
uint256 public lastRewardCalculationTime;
uint256 public rewardPerTokenStored;
uint256 public stakingWithdrawalTimeLock = 3 days;
uint256 public withdrawalFeePercentage = 0;
uint256 public rewardsEmissionStart;
uint256 public rewardsEmissionEnd;
uint256 public feesAccrued;
uint256 public storedPendingRewards;
uint256 private constant MAX_FEE = 200;
uint256 private constant BASIS_POINTS = 10000;
uint256 private constant MAX_TIMELOCK = 15 days;
struct Staker {
uint256 amountStaked;
uint256 rewardDebt;
uint256 rewards;
uint256 unstakeInitTime;
}
mapping(address => Staker) public stakers;
event UnstakeInitiated(address indexed user);
event Staked(address indexed user, uint256 amount);
event Unstaked(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event UnstakeFeePercentUpdated(uint256 newFeePercent);
event UnstakeTimeLockUpdated(uint256 newTimeLock);
modifier updateReward(address account) {
rewardPerTokenStored = calculateRewardPerToken();
storedPendingRewards = calculatePendingRewards();
lastRewardCalculationTime = getLastActiveTime();
Staker storage staker = stakers[account];
if (staker.unstakeInitTime == 0) {
staker.rewards = calculateEarnedRewards(account);
staker.rewardDebt = rewardPerTokenStored;
}
_;
}
constructor(
address _Mirai,
uint256 _rewardRate,
uint256 _rewardsEmissionStart,
uint256 _emissionDuration
) Ownable(msg.sender) {
Token = IERC20(_Mirai);
currentRewardRate = _rewardRate;
rewardsEmissionStart = _rewardsEmissionStart;
rewardsEmissionEnd = rewardsEmissionStart + _emissionDuration;
}
function getLastActiveTime() public view returns (uint256) {
return block.timestamp < rewardsEmissionEnd ? block.timestamp : rewardsEmissionEnd;
}
function calculatePendingRewards() public view returns (uint256) {
uint256 totalStakedAccruingRewardsCached = totalStakedAccruingRewards;
if (totalStakedAccruingRewardsCached == 0) return storedPendingRewards;
uint256 fullPendingRewards = (getLastActiveTime() - lastRewardCalculationTime) *
currentRewardRate *
1e18;
uint256 roundingError = fullPendingRewards %
totalStakedAccruingRewardsCached;
return storedPendingRewards + fullPendingRewards - roundingError;
}
function calculateRewardPerToken() public view returns (uint256) {
if (totalStakedAccruingRewards == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored +
(((getLastActiveTime() - lastRewardCalculationTime) * currentRewardRate * 1e18) /
totalStakedAccruingRewards);
}
function calculateEarnedRewards(address account) public view returns (uint256) {
Staker storage staker = stakers[account];
if (staker.unstakeInitTime != 0) {
return staker.rewards;
}
return
((staker.amountStaked * (calculateRewardPerToken() - staker.rewardDebt)) /
1e18) + staker.rewards;
}
function depositStake(
uint256 _amount
) external nonReentrant updateReward(msg.sender) {
require(_amount > 0, "Cannot stake 0");
require(block.timestamp >= rewardsEmissionStart, "Staking not yet started");
require(block.timestamp <= rewardsEmissionEnd, "Staking period has ended");
Staker storage staker = stakers[msg.sender];
require(
staker.unstakeInitTime == 0,
"Cannot stake after initiating unstake."
);
totalTokensStaked += _amount;
totalStakedAccruingRewards += _amount;
staker.amountStaked += _amount;
require(
Token.transferFrom(msg.sender, address(this), _amount),
"Token deposit failed"
);
emit Staked(msg.sender, _amount);
}
function beginUnstaking() external updateReward(msg.sender) {
Staker storage staker = stakers[msg.sender];
require(staker.amountStaked > 0, "No tokens staked");
require(staker.unstakeInitTime == 0, "Unstake already initiated");
staker.unstakeInitTime = block.timestamp;
totalStakedAccruingRewards -= staker.amountStaked;
emit UnstakeInitiated(msg.sender);
}
function finalizeUnstaking() external nonReentrant updateReward(msg.sender) {
Staker storage staker = stakers[msg.sender];
require(staker.amountStaked > 0, "No tokens staked");
require(staker.unstakeInitTime > 0, "Unstake not initiated");
require(
block.timestamp >= staker.unstakeInitTime + stakingWithdrawalTimeLock ,
"Timelock not yet passed"
);
uint256 amount = staker.amountStaked;
uint256 reward = staker.rewards;
uint256 fee = (amount * withdrawalFeePercentage ) / BASIS_POINTS;
uint256 amountAfterFee = amount - fee;
uint256 availableForRewards = _calculateAvailableBalance();
feesAccrued += fee;
totalTokensStaked -= amount;
staker.amountStaked = 0;
staker.rewardDebt = 0;
staker.unstakeInitTime = 0;
uint256 totalAmount = amountAfterFee;
// If there are rewards, combine them with the staked amount after fees for a single transfer
if (reward > 0 && availableForRewards >= reward) {
if (storedPendingRewards >= reward * 1e18)
storedPendingRewards -= reward * 1e18;
totalAmount += reward;
staker.rewards = 0;
emit RewardPaid(msg.sender, reward);
}
require(
Token.transfer(msg.sender, totalAmount),
"Unstake transfer failed"
);
emit Unstaked(msg.sender, amount);
}
function withdrawRewards() external nonReentrant updateReward(msg.sender) {
Staker storage staker = stakers[msg.sender];
uint256 reward = staker.rewards;
require(reward > 0, "No rewards to claim");
// Calculate the available balance for rewards
uint256 availableForRewards = _calculateAvailableBalance();
require(availableForRewards >= reward, "Insufficient funds for reward");
if (storedPendingRewards >= reward * 1e18)
storedPendingRewards -= reward * 1e18;
staker.rewards = 0;
require(Token.transfer(msg.sender, reward), "Reward transfer failed");
emit RewardPaid(msg.sender, reward);
}
function updateUnstakingFee(uint256 _newFee) external onlyOwner {
require(_newFee <= MAX_FEE, "Unstake fee exceeds 2%, maximum allowed");
withdrawalFeePercentage = _newFee;
emit UnstakeFeePercentUpdated(_newFee);
}
function updateWithdrawalLock(uint256 _newTimeLock) external onlyOwner {
require(
_newTimeLock <= MAX_TIMELOCK,
"Time lock must be between 0 to 15 days"
);
stakingWithdrawalTimeLock = _newTimeLock;
emit UnstakeTimeLockUpdated(_newTimeLock);
}
function checkRemainingLockTime(
address _staker
) external view returns (uint256) {
Staker storage staker = stakers[_staker];
if (block.timestamp < staker.unstakeInitTime + stakingWithdrawalTimeLock ) {
return (staker.unstakeInitTime + stakingWithdrawalTimeLock ) - block.timestamp;
} else {
return 0;
}
}
function retrieveAccruedFees(uint256 amount) external onlyOwner {
require(amount <= feesAccrued, "Amount exceeds accrued fees");
feesAccrued -= amount;
require(Token.transfer(msg.sender, amount), "Fee withdrawal failed");
}
function retrieveRemainingTokens()
external
updateReward(address(0))
onlyOwner
{
require(
block.timestamp > rewardsEmissionEnd,
"Cannot withdraw before emission end"
);
uint256 freeContractBalanceCached = _calculateAvailableBalance();
uint256 pendingRewardsCached = calculatePendingRewards() / 1e18;
require(
freeContractBalanceCached > pendingRewardsCached,
"No remaining tokens to withdraw"
);
uint256 remainingBalance = freeContractBalanceCached -
pendingRewardsCached;
require(
Token.transfer(msg.sender, remainingBalance),
"Token withdrawal failed"
);
}
function _calculateAvailableBalance() public view returns (uint256) {
return Token.balanceOf(address(this)) - totalTokensStaked - feesAccrued;
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
Read Contract
Token 0xc2412676 → address
_calculateAvailableBalance 0x640393d3 → uint256
calculateEarnedRewards 0xd3cd1c7c → uint256
calculatePendingRewards 0x7c777ec9 → uint256
calculateRewardPerToken 0x639793fa → uint256
checkRemainingLockTime 0x93329f86 → uint256
currentRewardRate 0xf51ace70 → uint256
feesAccrued 0x94db0595 → uint256
getLastActiveTime 0xb8017874 → uint256
lastRewardCalculationTime 0xef7ec387 → uint256
owner 0x8da5cb5b → address
rewardPerTokenStored 0xdf136d65 → uint256
rewardsEmissionEnd 0xb4e55fc6 → uint256
rewardsEmissionStart 0xd9132b22 → uint256
stakers 0x9168ae72 → uint256, uint256, uint256, uint256
stakingWithdrawalTimeLock 0x1b65cd63 → uint256
storedPendingRewards 0x2df0b5e8 → uint256
totalStakedAccruingRewards 0x0976769d → uint256
totalTokensStaked 0xb0e31b2d → uint256
withdrawalFeePercentage 0x78922c8f → uint256
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
beginUnstaking 0x3f3d977a
No parameters
depositStake 0xcb82cc8f
uint256 _amount
finalizeUnstaking 0x8df4cf2e
No parameters
renounceOwnership 0x715018a6
No parameters
retrieveAccruedFees 0xdc9126ca
uint256 amount
retrieveRemainingTokens 0x62fce4c4
No parameters
transferOwnership 0xf2fde38b
address newOwner
updateUnstakingFee 0x09f6ae14
uint256 _newFee
updateWithdrawalLock 0xf0d9247e
uint256 _newTimeLock
withdrawRewards 0xc7b8981c
No parameters
Recent Transactions
No transactions found for this address