// SPDX-License-Identifier: MIT
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;
}
}
/**
* @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 Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
/**
* @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 Collection of functions related to the address type
*/
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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return 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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 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
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 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'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_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(IERC20 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, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
interface IMasterChefV2 {
function deposit(uint256 _pid, uint256 _amount) external;
function withdraw(uint256 _pid, uint256 _amount) external;
function pendingArx(uint256 _pid, address _user) external view returns (uint256);
function userInfo(uint256 _pid, address _user) external view returns (uint256, uint256);
function emergencyWithdraw(uint256 _pid) external;
}
pragma solidity ^0.8.0;
contract ARXPool is Ownable, Pausable {
using SafeERC20 for IERC20;
struct UserInfo {
uint256 shares; // number of shares for a user.
uint256 lastDepositedTime; // keep track of deposited time for potential penalty.
uint256 arxAtLastUserAction; // keep track of ARX deposited at the last user action.
uint256 lastUserActionTime; // keep track of the last user action time.
uint256 lockStartTime; // lock start time.
uint256 lockEndTime; // lock end time.
uint256 userBoostedShare; // boost share, in order to give the user higher reward. The user only enjoys the reward, so the principal needs to be recorded as a debt.
bool locked; //lock status.
uint256 lockedAmount; // amount deposited during lock period.
}
IERC20 public immutable token; // ARX token.
IMasterChefV2 public immutable masterchefV2;
mapping(address => UserInfo) public userInfo;
mapping(address => bool) public freePerformanceFeeUsers; // free performance fee users.
mapping(address => bool) public freeWithdrawFeeUsers; // free withdraw fee users.
mapping(address => bool) public freeOverdueFeeUsers; // free overdue fee users.
uint256 public totalShares;
address public treasury;
uint256 public arxPoolPID;
uint256 public totalBoostDebt; // total boost debt.
uint256 public totalLockedAmount; // total lock amount.
uint256 public constant MAX_PERFORMANCE_FEE = 2000; // 20%
uint256 public constant MAX_WITHDRAW_FEE = 500; // 5%
uint256 public constant MAX_OVERDUE_FEE = 100 * 1e10; // 100%
uint256 public constant MAX_WITHDRAW_FEE_PERIOD = 1 weeks; // 1 week
uint256 public constant MIN_LOCK_DURATION = 1 weeks; // 1 week
uint256 public constant MAX_LOCK_DURATION_LIMIT = 1000 days; // 1000 days
uint256 public constant PRECISION_FACTOR = 1e12; // precision factor.
uint256 public constant PRECISION_FACTOR_SHARE = 1e28; // precision factor for share.
uint256 public constant MIN_DEPOSIT_AMOUNT = 0.00001 ether;
uint256 public constant MIN_WITHDRAW_AMOUNT = 0.00001 ether;
uint256 public UNLOCK_FREE_DURATION = 1 weeks; // 1 week
uint256 public MAX_LOCK_DURATION = 365 days; // 365 days
uint256 public DURATION_FACTOR = 365 days; // 365 days, in order to calculate user additional boost.
uint256 public DURATION_FACTOR_OVERDUE = 180 days; // 180 days, in order to calculate overdue fee.
uint256 public BOOST_WEIGHT = 100 * 1e10; // 100%
uint256 public performanceFee = 200; // 2%
uint256 public performanceFeeContract = 200; // 2%
uint256 public withdrawFee = 10; // 0.1%
uint256 public withdrawFeeContract = 10; // 0.1%
uint256 public overdueFee = 100 * 1e10; // 100%
uint256 public withdrawFeePeriod = 72 hours; // 3 days
event Deposit(address indexed sender, uint256 amount, uint256 shares, uint256 duration, uint256 lastDepositedTime);
event Withdraw(address indexed sender, uint256 amount, uint256 shares);
event Harvest(address indexed sender, uint256 amount);
event Pause();
event Unpause();
event Init();
event Lock(
address indexed sender,
uint256 lockedAmount,
uint256 shares,
uint256 lockedDuration,
uint256 blockTimestamp
);
event Unlock(address indexed sender, uint256 amount, uint256 blockTimestamp);
event NewTreasury(address treasury);
event FreeFeeUser(address indexed user, bool indexed free);
event NewPerformanceFee(uint256 performanceFee);
event NewPerformanceFeeContract(uint256 performanceFeeContract);
event NewWithdrawFee(uint256 withdrawFee);
event NewOverdueFee(uint256 overdueFee);
event NewWithdrawFeeContract(uint256 withdrawFeeContract);
event NewWithdrawFeePeriod(uint256 withdrawFeePeriod);
event NewMaxLockDuration(uint256 maxLockDuration);
event NewDurationFactor(uint256 durationFactor);
event NewDurationFactorOverdue(uint256 durationFactorOverdue);
event NewUnlockFreeDuration(uint256 unlockFreeDuration);
event NewBoostWeight(uint256 boostWeight);
/**
* @notice Constructor
* @param _token: ARX token contract
* @param _masterchefV2: MasterChefV2 contract
* @param _treasury: address of the treasury (collects fees)
* @param _pid: ARX pool ID in MasterChefV2
*/
constructor(
IERC20 _token,
IMasterChefV2 _masterchefV2,
address _treasury,
uint256 _pid
) {
token = _token;
masterchefV2 = _masterchefV2;
treasury = _treasury;
arxPoolPID = _pid;
}
/**
* @notice Deposits a dummy token to `MASTER_CHEF` MCV2.
* It will transfer all the `dummyToken` in the tx sender address.
* @param dummyToken The address of the token to be deposited into MCV2.
*/
function init(IERC20 dummyToken) external onlyOwner {
uint256 balance = dummyToken.balanceOf(msg.sender);
require(balance != 0, "Balance must exceed 0");
dummyToken.safeTransferFrom(msg.sender, address(this), balance);
dummyToken.approve(address(masterchefV2), balance);
masterchefV2.deposit(arxPoolPID, balance);
emit Init();
}
/**
* @notice Update user share When need to unlock or charges a fee.
* @param _user: User address
*/
function updateUserShare(address _user) internal {
UserInfo storage user = userInfo[_user];
if (user.shares > 0) {
if (user.locked) {
// Calculate the user's current token amount and update related parameters.
uint256 currentAmount = (balanceOf() * (user.shares)) / totalShares - user.userBoostedShare;
totalBoostDebt -= user.userBoostedShare;
user.userBoostedShare = 0;
totalShares -= user.shares;
//Charge a overdue fee after the free duration has expired.
if (!freeOverdueFeeUsers[_user] && ((user.lockEndTime + UNLOCK_FREE_DURATION) < block.timestamp)) {
uint256 earnAmount = currentAmount - user.lockedAmount;
uint256 overdueDuration = block.timestamp - user.lockEndTime - UNLOCK_FREE_DURATION;
if (overdueDuration > DURATION_FACTOR_OVERDUE) {
overdueDuration = DURATION_FACTOR_OVERDUE;
}
// Rates are calculated based on the user's overdue duration.
uint256 overdueWeight = (overdueDuration * overdueFee) / DURATION_FACTOR_OVERDUE;
uint256 currentOverdueFee = (earnAmount * overdueWeight) / PRECISION_FACTOR;
token.safeTransfer(treasury, currentOverdueFee);
currentAmount -= currentOverdueFee;
}
// Recalculate the user's share.
uint256 pool = balanceOf();
uint256 currentShares;
if (totalShares != 0) {
currentShares = (currentAmount * totalShares) / (pool - currentAmount);
} else {
currentShares = currentAmount;
}
user.shares = currentShares;
totalShares += currentShares;
// After the lock duration, update related parameters.
if (user.lockEndTime < block.timestamp) {
user.locked = false;
user.lockStartTime = 0;
user.lockEndTime = 0;
totalLockedAmount -= user.lockedAmount;
user.lockedAmount = 0;
emit Unlock(_user, currentAmount, block.timestamp);
}
} else if (!freePerformanceFeeUsers[_user]) {
// Calculate Performance fee.
uint256 totalAmount = (user.shares * balanceOf()) / totalShares;
totalShares -= user.shares;
user.shares = 0;
uint256 earnAmount = totalAmount - user.arxAtLastUserAction;
uint256 feeRate = performanceFee;
if (_isContract(_user)) {
feeRate = performanceFeeContract;
}
uint256 currentPerformanceFee = (earnAmount * feeRate) / 10000;
if (currentPerformanceFee > 0) {
token.safeTransfer(treasury, currentPerformanceFee);
totalAmount -= currentPerformanceFee;
}
// Recalculate the user's share.
uint256 pool = balanceOf();
uint256 newShares;
if (totalShares != 0) {
newShares = (totalAmount * totalShares) / (pool - totalAmount);
} else {
newShares = totalAmount;
}
user.shares = newShares;
totalShares += newShares;
}
}
}
/**
* @notice Unlock user ARX funds.
* @dev Only possible when contract not paused.
* @param _user: User address
*/
function unlock(address _user) external onlyOwner whenNotPaused {
UserInfo storage user = userInfo[_user];
require(user.locked && user.lockEndTime < block.timestamp, "Cannot unlock yet");
depositOperation(0, 0, _user);
}
/**
* @notice Deposit funds into the ARX Pool.
* @dev Only possible when contract not paused.
* @param _amount: number of tokens to deposit (in ARX)
* @param _lockDuration: Token lock duration
*/
function deposit(uint256 _amount, uint256 _lockDuration) external whenNotPaused {
require(_amount > 0 || _lockDuration > 0, "Nothing to deposit");
depositOperation(_amount, _lockDuration, msg.sender);
}
/**
* @notice The operation of deposite.
* @param _amount: number of tokens to deposit (in ARX)
* @param _lockDuration: Token lock duration
* @param _user: User address
*/
function depositOperation(
uint256 _amount,
uint256 _lockDuration,
address _user
) internal {
UserInfo storage user = userInfo[_user];
if (user.shares == 0 || _amount > 0) {
require(_amount > MIN_DEPOSIT_AMOUNT, "Deposit amount must be greater than MIN_DEPOSIT_AMOUNT");
}
// Calculate the total lock duration and check whether the lock duration meets the conditions.
uint256 totalLockDuration = _lockDuration;
if (user.lockEndTime >= block.timestamp) {
// Adding funds during the lock duration is equivalent to re-locking the position, needs to update some variables.
if (_amount > 0) {
user.lockStartTime = block.timestamp;
totalLockedAmount -= user.lockedAmount;
user.lockedAmount = 0;
}
totalLockDuration += user.lockEndTime - user.lockStartTime;
}
require(_lockDuration == 0 || totalLockDuration >= MIN_LOCK_DURATION, "Minimum lock period is one week");
require(totalLockDuration <= MAX_LOCK_DURATION, "Maximum lock period exceeded");
// Harvest tokens from Masterchef.
harvest();
// Handle stock funds.
if (totalShares == 0) {
uint256 stockAmount = available();
token.safeTransfer(treasury, stockAmount);
}
// Update user share.
updateUserShare(_user);
// Update lock duration.
if (_lockDuration > 0) {
if (user.lockEndTime < block.timestamp) {
user.lockStartTime = block.timestamp;
user.lockEndTime = block.timestamp + _lockDuration;
} else {
user.lockEndTime += _lockDuration;
}
user.locked = true;
}
uint256 currentShares;
uint256 currentAmount;
uint256 userCurrentLockedBalance;
uint256 pool = balanceOf();
if (_amount > 0) {
token.safeTransferFrom(_user, address(this), _amount);
currentAmount = _amount;
}
// Calculate lock funds
if (user.shares > 0 && user.locked) {
userCurrentLockedBalance = (pool * user.shares) / totalShares;
currentAmount += userCurrentLockedBalance;
totalShares -= user.shares;
user.shares = 0;
// Update lock amount
if (user.lockStartTime == block.timestamp) {
user.lockedAmount = userCurrentLockedBalance;
totalLockedAmount += user.lockedAmount;
}
}
if (totalShares != 0) {
currentShares = (currentAmount * totalShares) / (pool - userCurrentLockedBalance);
} else {
currentShares = currentAmount;
}
// Calculate the boost weight share.
if (user.lockEndTime > user.lockStartTime) {
// Calculate boost share.
uint256 boostWeight = ((user.lockEndTime - user.lockStartTime) * BOOST_WEIGHT) / DURATION_FACTOR;
uint256 boostShares = (boostWeight * currentShares) / PRECISION_FACTOR;
currentShares += boostShares;
user.shares += currentShares;
// Calculate boost share , the user only enjoys the reward, so the principal needs to be recorded as a debt.
uint256 userBoostedShare = (boostWeight * currentAmount) / PRECISION_FACTOR;
user.userBoostedShare += userBoostedShare;
totalBoostDebt += userBoostedShare;
// Update lock amount.
user.lockedAmount += _amount;
totalLockedAmount += _amount;
emit Lock(_user, user.lockedAmount, user.shares, (user.lockEndTime - user.lockStartTime), block.timestamp);
} else {
user.shares += currentShares;
}
if (_amount > 0 || _lockDuration > 0) {
user.lastDepositedTime = block.timestamp;
}
totalShares += currentShares;
user.arxAtLastUserAction = (user.shares * balanceOf()) / totalShares - user.userBoostedShare;
user.lastUserActionTime = block.timestamp;
emit Deposit(_user, _amount, currentShares, _lockDuration, block.timestamp);
}
/**
* @notice Withdraw funds from the ARX Pool.
* @param _amount: Number of amount to withdraw
*/
function withdrawByAmount(uint256 _amount) public whenNotPaused {
require(_amount > MIN_WITHDRAW_AMOUNT, "Withdraw amount must be greater than MIN_WITHDRAW_AMOUNT");
withdrawOperation(0, _amount);
}
/**
* @notice Withdraw funds from the ARX Pool.
* @param _shares: Number of shares to withdraw
*/
function withdraw(uint256 _shares) public whenNotPaused {
require(_shares > 0, "Nothing to withdraw");
withdrawOperation(_shares, 0);
}
/**
* @notice The operation of withdraw.
* @param _shares: Number of shares to withdraw
* @param _amount: Number of amount to withdraw
*/
function withdrawOperation(uint256 _shares, uint256 _amount) internal {
UserInfo storage user = userInfo[msg.sender];
require(_shares <= user.shares, "Withdraw amount exceeds balance");
require(user.lockEndTime < block.timestamp, "Still in lock");
// Calculate the percent of withdraw shares, when unlocking or calculating the Performance fee, the shares will be updated.
uint256 currentShare = _shares;
uint256 sharesPercent = (_shares * PRECISION_FACTOR_SHARE) / user.shares;
// Harvest token from MasterchefV2.
harvest();
// Update user share.
updateUserShare(msg.sender);
if (_shares == 0 && _amount > 0) {
uint256 pool = balanceOf();
currentShare = (_amount * totalShares) / pool; // Calculate equivalent shares
if (currentShare > user.shares) {
currentShare = user.shares;
}
} else {
currentShare = (sharesPercent * user.shares) / PRECISION_FACTOR_SHARE;
}
uint256 currentAmount = (balanceOf() * currentShare) / totalShares;
user.shares -= currentShare;
totalShares -= currentShare;
// Calculate withdraw fee
if (!freeWithdrawFeeUsers[msg.sender] && (block.timestamp < user.lastDepositedTime + withdrawFeePeriod)) {
uint256 feeRate = withdrawFee;
if (_isContract(msg.sender)) {
feeRate = withdrawFeeContract;
}
uint256 currentWithdrawFee = (currentAmount * feeRate) / 10000;
token.safeTransfer(treasury, currentWithdrawFee);
currentAmount -= currentWithdrawFee;
}
token.safeTransfer(msg.sender, currentAmount);
if (user.shares > 0) {
user.arxAtLastUserAction = (user.shares * balanceOf()) / totalShares;
} else {
user.arxAtLastUserAction = 0;
}
user.lastUserActionTime = block.timestamp;
emit Withdraw(msg.sender, currentAmount, currentShare);
}
/**
* @notice Withdraw all funds for a user
*/
function withdrawAll() external {
withdraw(userInfo[msg.sender].shares);
}
/**
* @notice Harvest pending ARX tokens from MasterChef
*/
function harvest() internal {
uint256 pendingARX = masterchefV2.pendingArx(arxPoolPID, address(this));
if (pendingARX > 0) {
uint256 balBefore = available();
masterchefV2.withdraw(arxPoolPID, 0);
uint256 balAfter = available();
emit Harvest(msg.sender, (balAfter - balBefore));
}
}
/**
* @notice Set treasury address
* @dev Only callable by the contract owner.
*/
function setTreasury(address _treasury) external onlyOwner {
require(_treasury != address(0), "Cannot be zero address");
treasury = _treasury;
emit NewTreasury(treasury);
}
/**
* @notice Set free performance fee address
* @dev Only callable by the contract owner.
* @param _user: User address
* @param _free: true:free false:not free
*/
function setFreePerformanceFeeUser(address _user, bool _free) external onlyOwner {
require(_user != address(0), "Cannot be zero address");
freePerformanceFeeUsers[_user] = _free;
emit FreeFeeUser(_user, _free);
}
/**
* @notice Set free overdue fee address
* @dev Only callable by the contract owner.
* @param _user: User address
* @param _free: true:free false:not free
*/
function setOverdueFeeUser(address _user, bool _free) external onlyOwner {
require(_user != address(0), "Cannot be zero address");
freeOverdueFeeUsers[_user] = _free;
emit FreeFeeUser(_user, _free);
}
/**
* @notice Set free withdraw fee address
* @dev Only callable by the contract owner.
* @param _user: User address
* @param _free: true:free false:not free
*/
function setWithdrawFeeUser(address _user, bool _free) external onlyOwner {
require(_user != address(0), "Cannot be zero address");
freeWithdrawFeeUsers[_user] = _free;
emit FreeFeeUser(_user, _free);
}
/**
* @notice Set performance fee
* @dev Only callable by the contract owner.
*/
function setPerformanceFee(uint256 _performanceFee) external onlyOwner {
require(_performanceFee <= MAX_PERFORMANCE_FEE, "performanceFee cannot be more than MAX_PERFORMANCE_FEE");
performanceFee = _performanceFee;
emit NewPerformanceFee(performanceFee);
}
/**
* @notice Set performance fee for contract
* @dev Only callable by the contract owner.
*/
function setPerformanceFeeContract(uint256 _performanceFeeContract) external onlyOwner {
require(
_performanceFeeContract <= MAX_PERFORMANCE_FEE,
"performanceFee cannot be more than MAX_PERFORMANCE_FEE"
);
performanceFeeContract = _performanceFeeContract;
emit NewPerformanceFeeContract(performanceFeeContract);
}
/**
* @notice Set withdraw fee
* @dev Only callable by the contract owner.
*/
function setWithdrawFee(uint256 _withdrawFee) external onlyOwner {
require(_withdrawFee <= MAX_WITHDRAW_FEE, "withdrawFee cannot be more than MAX_WITHDRAW_FEE");
withdrawFee = _withdrawFee;
emit NewWithdrawFee(withdrawFee);
}
/**
* @notice Set overdue fee
* @dev Only callable by the contract owner.
*/
function setOverdueFee(uint256 _overdueFee) external onlyOwner {
require(_overdueFee <= MAX_OVERDUE_FEE, "overdueFee cannot be more than MAX_OVERDUE_FEE");
overdueFee = _overdueFee;
emit NewOverdueFee(_overdueFee);
}
/**
* @notice Set withdraw fee for contract
* @dev Only callable by the contract owner.
*/
function setWithdrawFeeContract(uint256 _withdrawFeeContract) external onlyOwner {
require(_withdrawFeeContract <= MAX_WITHDRAW_FEE, "withdrawFee cannot be more than MAX_WITHDRAW_FEE");
withdrawFeeContract = _withdrawFeeContract;
emit NewWithdrawFeeContract(withdrawFeeContract);
}
/**
* @notice Set withdraw fee period
* @dev Only callable by the contract owner.
*/
function setWithdrawFeePeriod(uint256 _withdrawFeePeriod) external onlyOwner {
require(
_withdrawFeePeriod <= MAX_WITHDRAW_FEE_PERIOD,
"withdrawFeePeriod cannot be more than MAX_WITHDRAW_FEE_PERIOD"
);
withdrawFeePeriod = _withdrawFeePeriod;
emit NewWithdrawFeePeriod(withdrawFeePeriod);
}
/**
* @notice Set MAX_LOCK_DURATION
* @dev Only callable by the contract owner.
*/
function setMaxLockDuration(uint256 _maxLockDuration) external onlyOwner {
require(
_maxLockDuration <= MAX_LOCK_DURATION_LIMIT,
"MAX_LOCK_DURATION cannot be more than MAX_LOCK_DURATION_LIMIT"
);
MAX_LOCK_DURATION = _maxLockDuration;
emit NewMaxLockDuration(_maxLockDuration);
}
/**
* @notice Set DURATION_FACTOR
* @dev Only callable by the contract owner.
*/
function setDurationFactor(uint256 _durationFactor) external onlyOwner {
require(_durationFactor > 0, "DURATION_FACTOR cannot be zero");
DURATION_FACTOR = _durationFactor;
emit NewDurationFactor(_durationFactor);
}
/**
* @notice Set DURATION_FACTOR_OVERDUE
* @dev Only callable by the contract owner.
*/
function setDurationFactorOverdue(uint256 _durationFactorOverdue) external onlyOwner {
require(_durationFactorOverdue > 0, "DURATION_FACTOR_OVERDUE cannot be zero");
DURATION_FACTOR_OVERDUE = _durationFactorOverdue;
emit NewDurationFactorOverdue(_durationFactorOverdue);
}
/**
* @notice Set UNLOCK_FREE_DURATION
* @dev Only callable by the contract owner.
*/
function setUnlockFreeDuration(uint256 _unlockFreeDuration) external onlyOwner {
require(_unlockFreeDuration > 0, "UNLOCK_FREE_DURATION cannot be zero");
UNLOCK_FREE_DURATION = _unlockFreeDuration;
emit NewUnlockFreeDuration(_unlockFreeDuration);
}
/**
* @notice Withdraw unexpected tokens sent to the ARX Pool
*/
function inCaseTokensGetStuck(address _token) external onlyOwner {
require(_token != address(token), "Token cannot be same as deposit token");
uint256 amount = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(msg.sender, amount);
}
/**
* @notice Trigger stopped state
* @dev Only possible when contract not paused.
*/
function pause() external onlyOwner whenNotPaused {
_pause();
emit Pause();
}
/**
* @notice Return to normal state
* @dev Only possible when contract is paused.
*/
function unpause() external onlyOwner whenPaused {
_unpause();
emit Unpause();
}
/**
* @notice Calculate Performance fee.
* @param _user: User address
* @return Returns Performance fee.
*/
function calculatePerformanceFee(address _user) public view returns (uint256) {
UserInfo storage user = userInfo[_user];
if (user.shares > 0 && !user.locked && !freePerformanceFeeUsers[_user]) {
uint256 pool = balanceOf() + calculateTotalPendingARXRewards();
uint256 totalAmount = (user.shares * pool) / totalShares;
uint256 earnAmount = totalAmount - user.arxAtLastUserAction;
uint256 feeRate = performanceFee;
if (_isContract(_user)) {
feeRate = performanceFeeContract;
}
uint256 currentPerformanceFee = (earnAmount * feeRate) / 10000;
return currentPerformanceFee;
}
return 0;
}
/**
* @notice Calculate overdue fee.
* @param _user: User address
* @return Returns Overdue fee.
*/
function calculateOverdueFee(address _user) public view returns (uint256) {
UserInfo storage user = userInfo[_user];
if (
user.shares > 0 &&
user.locked &&
!freeOverdueFeeUsers[_user] &&
((user.lockEndTime + UNLOCK_FREE_DURATION) < block.timestamp)
) {
uint256 pool = balanceOf() + calculateTotalPendingARXRewards();
uint256 currentAmount = (pool * (user.shares)) / totalShares - user.userBoostedShare;
uint256 earnAmount = currentAmount - user.lockedAmount;
uint256 overdueDuration = block.timestamp - user.lockEndTime - UNLOCK_FREE_DURATION;
if (overdueDuration > DURATION_FACTOR_OVERDUE) {
overdueDuration = DURATION_FACTOR_OVERDUE;
}
// Rates are calculated based on the user's overdue duration.
uint256 overdueWeight = (overdueDuration * overdueFee) / DURATION_FACTOR_OVERDUE;
uint256 currentOverdueFee = (earnAmount * overdueWeight) / PRECISION_FACTOR;
return currentOverdueFee;
}
return 0;
}
/**
* @notice Calculate Performance Fee Or Overdue Fee
* @param _user: User address
* @return Returns Performance Fee Or Overdue Fee.
*/
function calculatePerformanceFeeOrOverdueFee(address _user) internal view returns (uint256) {
return calculatePerformanceFee(_user) + calculateOverdueFee(_user);
}
/**
* @notice Calculate withdraw fee.
* @param _user: User address
* @param _shares: Number of shares to withdraw
* @return Returns Withdraw fee.
*/
function calculateWithdrawFee(address _user, uint256 _shares) public view returns (uint256) {
UserInfo storage user = userInfo[_user];
if (user.shares < _shares) {
_shares = user.shares;
}
if (!freeWithdrawFeeUsers[msg.sender] && (block.timestamp < user.lastDepositedTime + withdrawFeePeriod)) {
uint256 pool = balanceOf() + calculateTotalPendingARXRewards();
uint256 sharesPercent = (_shares * PRECISION_FACTOR) / user.shares;
uint256 currentTotalAmount = (pool * (user.shares)) /
totalShares -
user.userBoostedShare -
calculatePerformanceFeeOrOverdueFee(_user);
uint256 currentAmount = (currentTotalAmount * sharesPercent) / PRECISION_FACTOR;
uint256 feeRate = withdrawFee;
if (_isContract(msg.sender)) {
feeRate = withdrawFeeContract;
}
uint256 currentWithdrawFee = (currentAmount * feeRate) / 10000;
return currentWithdrawFee;
}
return 0;
}
/**
* @notice Calculates the total pending rewards that can be harvested
* @return Returns total pending ARX rewards
*/
function calculateTotalPendingARXRewards() public view returns (uint256) {
uint256 amount = masterchefV2.pendingArx(arxPoolPID, address(this));
return amount;
}
function getPricePerFullShare() external view returns (uint256) {
return totalShares == 0 ? 1e18 : (((balanceOf() + calculateTotalPendingARXRewards()) * (1e18)) / totalShares);
}
/**
* @notice Current pool available balance
* @dev The contract puts 100% of the tokens to work.
*/
function available() public view returns (uint256) {
return token.balanceOf(address(this));
}
/**
* @notice Calculates the total underlying tokens
* @dev It includes tokens held by the contract and the boost debt amount.
*/
function balanceOf() public view returns (uint256) {
return token.balanceOf(address(this)) + totalBoostDebt;
}
/**
* @notice Checks if address is a contract
*/
function _isContract(address addr) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(addr)
}
return size > 0;
}
}
{
"compilationTarget": {
"ARXPool.sol": "ARXPool"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IMasterChefV2","name":"_masterchefV2","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastDepositedTime","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"bool","name":"free","type":"bool"}],"name":"FreeFeeUser","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[],"name":"Init","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"lockedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockedDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"name":"Lock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"boostWeight","type":"uint256"}],"name":"NewBoostWeight","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"durationFactor","type":"uint256"}],"name":"NewDurationFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"durationFactorOverdue","type":"uint256"}],"name":"NewDurationFactorOverdue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxLockDuration","type":"uint256"}],"name":"NewMaxLockDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"overdueFee","type":"uint256"}],"name":"NewOverdueFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"performanceFee","type":"uint256"}],"name":"NewPerformanceFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"performanceFeeContract","type":"uint256"}],"name":"NewPerformanceFeeContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"treasury","type":"address"}],"name":"NewTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"unlockFreeDuration","type":"uint256"}],"name":"NewUnlockFreeDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"withdrawFee","type":"uint256"}],"name":"NewWithdrawFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"withdrawFeeContract","type":"uint256"}],"name":"NewWithdrawFeeContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"withdrawFeePeriod","type":"uint256"}],"name":"NewWithdrawFeePeriod","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":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"name":"Unlock","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"BOOST_WEIGHT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DURATION_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DURATION_FACTOR_OVERDUE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_LOCK_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_LOCK_DURATION_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_OVERDUE_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PERFORMANCE_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WITHDRAW_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WITHDRAW_FEE_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DEPOSIT_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_LOCK_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_WITHDRAW_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION_FACTOR_SHARE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNLOCK_FREE_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"arxPoolPID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"available","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"calculateOverdueFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"calculatePerformanceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateTotalPendingARXRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"calculateWithdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockDuration","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"freeOverdueFeeUsers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"freePerformanceFeeUsers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"freeWithdrawFeeUsers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPricePerFullShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"inCaseTokensGetStuck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"dummyToken","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"masterchefV2","outputs":[{"internalType":"contract IMasterChefV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overdueFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performanceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performanceFeeContract","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_durationFactor","type":"uint256"}],"name":"setDurationFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_durationFactorOverdue","type":"uint256"}],"name":"setDurationFactorOverdue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_free","type":"bool"}],"name":"setFreePerformanceFeeUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxLockDuration","type":"uint256"}],"name":"setMaxLockDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_overdueFee","type":"uint256"}],"name":"setOverdueFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_free","type":"bool"}],"name":"setOverdueFeeUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_performanceFee","type":"uint256"}],"name":"setPerformanceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_performanceFeeContract","type":"uint256"}],"name":"setPerformanceFeeContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_unlockFreeDuration","type":"uint256"}],"name":"setUnlockFreeDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawFee","type":"uint256"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawFeeContract","type":"uint256"}],"name":"setWithdrawFeeContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawFeePeriod","type":"uint256"}],"name":"setWithdrawFeePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_free","type":"bool"}],"name":"setWithdrawFeeUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBoostDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"lastDepositedTime","type":"uint256"},{"internalType":"uint256","name":"arxAtLastUserAction","type":"uint256"},{"internalType":"uint256","name":"lastUserActionTime","type":"uint256"},{"internalType":"uint256","name":"lockStartTime","type":"uint256"},{"internalType":"uint256","name":"lockEndTime","type":"uint256"},{"internalType":"uint256","name":"userBoostedShare","type":"uint256"},{"internalType":"bool","name":"locked","type":"bool"},{"internalType":"uint256","name":"lockedAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawByAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawFeeContract","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawFeePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]