Description:
Decentralized Finance (DeFi) protocol contract providing Factory functionality.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/lockedStake.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
interface IflexibleStake {
struct PoolInfo {
uint256 lastRewardBlock;
uint256 apy;
uint256 apyLk;
bool isRegular;
uint256 allocPoint;
}
// Getter function that must be implemented by the contract
function lpToken(uint256 _pid) external view returns (address);
function poolInfo(uint256 _pid) external view returns (PoolInfo memory);
function poolLength() external view returns (uint256);
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(
address target,
bytes memory data,
uint256 weiValue,
string memory errorMessage
) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{value: weiValue}(
data
);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
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 make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
abstract contract Ownable is Context {
address _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @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");
}
}
/**
* @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");
}
_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);
}
}
interface IBEP20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the bep token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
library SafeBEP20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(
IBEP20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transfer.selector, to, value)
);
}
function safeTransferFrom(
IBEP20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
);
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IBEP20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IBEP20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeBEP20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(
token,
abi.encodeWithSelector(token.approve.selector, spender, value)
);
}
function safeIncreaseAllowance(
IBEP20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(
value
);
_callOptionalReturn(
token,
abi.encodeWithSelector(
token.approve.selector,
spender,
newAllowance
)
);
}
function safeDecreaseAllowance(
IBEP20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(
value,
"SafeBEP20: decreased allowance below zero"
);
_callOptionalReturn(
token,
abi.encodeWithSelector(
token.approve.selector,
spender,
newAllowance
)
);
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IBEP20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(
data,
"SafeBEP20: low-level call failed"
);
if (returndata.length > 0) {
// Return data is optional
// solhint-disable-next-line max-line-length
require(
abi.decode(returndata, (bool)),
"SafeBEP20: BEP20 operation did not succeed"
);
}
}
}
contract lockLpStake is Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeBEP20 for IBEP20;
uint256 oneWeekTimeStamp = 604800;
uint16 oneMin = 60;
address public flexibleStake;
uint256 hundred = 100000000000000000000;
address public operator;
// Info of each user.
struct UserInfo {
uint256 amount;
uint256 rewardGetAmount;
uint256 lastRewardBlock;
uint256 rewardDebt;
uint256 unlockUntil;
uint256 unstaked;
uint256 stakeDuration;
uint256 unstakeUntil;
uint256 startTime;
uint256 userClaimRewards;
}
struct _PoolInfo {
uint256 lastRewardBlock;
uint256 apy;
bool isRegular;
uint256 allocPoint;
}
function poolInfo(uint256 _pid) public view returns (_PoolInfo memory) {
IflexibleStake.PoolInfo memory pool = IflexibleStake(flexibleStake).poolInfo(_pid);
return _PoolInfo({
lastRewardBlock: pool.lastRewardBlock,
apy: pool.apyLk,
isRegular: pool.isRegular,
allocPoint: pool.allocPoint
});
}
IBEP20 public GETX;
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event Claim(address indexed user, uint256 indexed pid, uint256 amount);
event UpdateEmission(uint256 amount, uint256 amountlp);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
event _ClaimReward(uint256 _pid, uint256 rewardDebt, address indexed user);
event Receive(address indexed user, uint256 amount);
address public owneraddress;
modifier onlyContractOwner() {
require(msg.sender == owneraddress , "onlyOwner");
_;
}
modifier onlyContractOwnerOrOperator() {
require(msg.sender == owneraddress || msg.sender == operator, "onlyOwnerOrOperator");
_;
}
constructor(IBEP20 _GETX , address _owneraddress,address _flexibleStake,address _operator) {
owneraddress = _owneraddress;
GETX = _GETX ;
flexibleStake= _flexibleStake;
operator =_operator;
}
function poolLength() external view returns (uint256) {
return IflexibleStake(flexibleStake).poolLength();
}
function getBlocktimeStamp() external view returns (uint256) {
return block.timestamp;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to)
public
pure
returns (uint256)
{
return _to.sub(_from);
}
function getLpTokens( uint256 _pid)
public view
returns (address)
{
return IflexibleStake(flexibleStake).lpToken(_pid);
}
// Deposit LP tokens to MasterChef for allocation.
function deposit(uint256 _pid, uint256 _amount, uint256 duration) public {
UserInfo storage user = userInfo[_pid][msg.sender];
require(duration <= 52,"give correct duration");
if(user.amount > 0){
revert();
}
if (_amount > 0) {
IBEP20(IflexibleStake(flexibleStake).lpToken(_pid)).safeTransferFrom(msg.sender, address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardGetAmount =user.rewardGetAmount.add(_amount);
user.stakeDuration = duration.mul(oneWeekTimeStamp);
user.lastRewardBlock = block.timestamp;
user.startTime = block.timestamp;
}
// poolInfo[_pid] = pool;
emit Deposit(msg.sender, _pid, _amount);
}
function Harvest(uint256 _pid) public nonReentrant {
_harvest(_pid);
}
function _harvest(uint256 _pid) internal {
_PoolInfo memory pool = poolInfo(_pid);
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 _apy = pool.apy;
if (user.rewardGetAmount > 0) {
uint256 multiplier = getMultiplier(
user.lastRewardBlock,
block.timestamp
);
uint256 aprInAmount = (user.rewardGetAmount.mul(_apy)).div(hundred);
uint256 apr_seconds = aprInAmount.div(user.stakeDuration);
uint256 pending = (apr_seconds.mul(multiplier));
if (pending > 0) {
// user.lastRewardBlock = block.timestamp;
uint256 rew = aprInAmount >= pending.add(user.userClaimRewards)
? pending
: user.userClaimRewards >= aprInAmount
? user.userClaimRewards.sub(aprInAmount)
:aprInAmount.sub(user.userClaimRewards);
user.rewardDebt = rew.add(user.rewardDebt);
uint256 totalAmount = (rew + user.userClaimRewards) * hundred/_apy;
user.rewardGetAmount = totalAmount >= user.rewardGetAmount?totalAmount - user.rewardGetAmount:user.rewardGetAmount - totalAmount;
}
}
}
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant {
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 blocks = user.lastRewardBlock + user.stakeDuration;
if (blocks <= block.timestamp) {
require(user.amount >= _amount, "withdraw: not good");
if (_amount > 0) {
_harvest(_pid);
require( GETX.balanceOf(address(this)) > user.rewardDebt,"GETX insuificient balance ");
user.amount = user.amount.sub(_amount);
IBEP20(IflexibleStake(flexibleStake).lpToken(_pid)).safeTransfer(msg.sender, _amount);
if (user.rewardDebt > 0) {
uint256 rewardBalance = user.rewardDebt;
if (rewardBalance > 0) {
GETX.safeTransfer(msg.sender, rewardBalance);
emit _ClaimReward(_pid, user.rewardDebt, msg.sender);
user.rewardDebt = 0;
if(user.rewardGetAmount > user.amount){
user.rewardGetAmount = user.amount;
user.userClaimRewards = 0;
}
}
} else {
user.rewardGetAmount = 0;
user.userClaimRewards = 0;
user.stakeDuration = 0;
}
user.unstaked = 0;
user.unstakeUntil = 0;
}
if (user.amount == 0) {
user.rewardGetAmount = 0;
user.userClaimRewards = 0;
user.stakeDuration = 0;
user.startTime = 0;
}
emit Withdraw(msg.sender, _pid, _amount);
}else{
revert("withdraw revert");
}
}
function getReward(uint256 _pid, address userAddress)
external
view
returns (uint256)
{
UserInfo storage user = userInfo[_pid][userAddress];
_PoolInfo memory pool = poolInfo(_pid);
uint256 _apy = pool.apy;
uint256 balancereward;
if (user.amount > 0) {
uint256 multiplier = getMultiplier(
user.lastRewardBlock,
block.timestamp
);
uint256 aprInAmount = (user.rewardGetAmount.mul(_apy)).div(hundred);
uint256 apr_seconds = aprInAmount.div(user.stakeDuration);
uint256 pending = (apr_seconds.mul(multiplier));
balancereward = aprInAmount >= pending?pending.add(user.rewardDebt):aprInAmount.add(user.rewardDebt);
}else{
balancereward =0;
}
return balancereward;
}
function ClaimReward(uint256 _pid) external {
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 blocks = user.lastRewardBlock + user.stakeDuration;
if (blocks <= block.timestamp) {
_harvest(_pid);
if (user.rewardDebt > 0) {
require(
GETX.balanceOf(address(this)) > user.rewardDebt,
"GETX insuificient balance "
);
GETX.safeTransfer(msg.sender, user.rewardDebt);
emit _ClaimReward(_pid, user.rewardDebt, msg.sender);
user.rewardDebt = 0;
}
}else{
revert("ClaimReward revert");
}
}
// Withdraw without caring about locking and rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public nonReentrant {
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardGetAmount =0;
user.rewardDebt =0;
user.userClaimRewards =0;
user.startTime = 0;
user.lastRewardBlock = block.timestamp;
IBEP20(IflexibleStake(flexibleStake).lpToken(_pid)).safeTransfer(msg.sender, amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
function updateEmissionAPY(uint256 _pid, uint256 _apy)
public
onlyContractOwnerOrOperator
{
_PoolInfo memory pool = poolInfo(_pid);
pool.apy = _apy;
emit UpdateEmission(_pid, _apy);
}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
function withdrawGETXbalance(uint256 _amount) public onlyContractOwner {
GETX.safeTransfer(msg.sender, _amount);
}
function getGETXbalance() public view returns (uint256) {
return GETX.balanceOf(address(this));
}
function getlptokens(uint256 _pid, uint256 _amount)
public
onlyContractOwner
{
IBEP20(IflexibleStake(flexibleStake).lpToken(_pid)).safeTransfer(msg.sender, _amount);
}
function recoverToken(address token, uint256 _amount)
public
onlyContractOwner
{
IBEP20(token).transfer(msg.sender, _amount);
}
function withdrawETH(address payable _to, uint256 _amount)
public
onlyContractOwner
nonReentrant
returns (uint256)
{
_to.transfer(_amount);
return _amount;
}
function changeOwner(address _ownerAddress)public onlyContractOwner{
owneraddress = _ownerAddress;
}
function changeOperator(address newOperator)public onlyContractOwnerOrOperator{
operator = newOperator;
}
function withdrawStatus(uint256 _pid, address _user)
public
view
returns (bool)
{
UserInfo storage user = userInfo[_pid][_user];
bool status;
uint256 blocks = user.lastRewardBlock + user.stakeDuration;
if (blocks <= block.timestamp) {
status = true;
} else {
status = false;
}
return status;
}
function rewardStatus(uint256 _pid, address _user)
public
view
returns (bool)
{
UserInfo storage user = userInfo[_pid][_user];
_PoolInfo memory pool = poolInfo(_pid);
bool status;
uint256 blocks = user.lastRewardBlock + user.stakeDuration;
uint256 aprAmount = (user.amount.mul(pool.apy)).div(hundred);
if (blocks <= block.timestamp||0 < user.rewardDebt||user.userClaimRewards == aprAmount) {
status = true;
} else {
status = false;
}
return status;
}
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-09-19 12:29:32
Comments
Log in to comment.
No comments yet.