Masterchef.sol

MasterChef Smart Contract: A Comprehensive Overview

The MasterChef contract is primarily used to manage liquidity pools and distribute rewards to liquidity providers. In the DeFi context, a liquidity pool is a collection of funds locked in a smart contract. Users deposit their assets into the pool and receive LP (Liquidity Provider) tokens in return.

The MasterChef contract is responsible for tracking all the LP tokens a user has provided and calculating the rewards that the user is entitled to. These rewards are typically additional tokens, distributed proportionally to the amount of liquidity each user has provided.

Construction Arguments

_token

_token

_token is the address of the token contract that will be used in the MasterChef contract.

_boosterNFT

_boosterNFT is the address of the booster NFT contract that will be used in the MasterChef contract. Pass 6 values on base 100 = 1% to set the NFT category discount. Example [ 100;200;300;500;1000;10000]

_tokenPerBlock

_tokenPerBlock

_tokenPerBlock is the amount of tokens that will be distributed per block in the MasterChef contract.

_startUnixTime

_startUnixTime is the Unix timestamp representing the start time of the MasterChef contract.

_devAddress

_devAddress is the address of the developer where the development fees will be sent to.

Read Functions

BONUS_MULTIPLIER

BONUS_MULTIPLIER

The BONUS_MULTIPLIER function is a public view function that does not take any arguments and returns a uint256 value. It is a getter function for the BONUS_MULTIPLIER variable. The BONUS_MULTIPLIER variable represents the multiplier applied to the bonus rewards earned by users in the contract. Users can use this function to retrieve the current value of the BONUS_MULTIPLIER variable, which determines the bonus rewards they will receive. The function does not have any prerequisites or restrictions on its usage.

MAXIMUM_REFERRAL_COMMISSION_RATE

MAXIMUM_REFERRAL_COMMISSION_RATE

The MAXIMUM_REFERRAL_COMMISSION_RATE function is a public view function that does not take any arguments. It returns a uint16 value, which represents the maximum referral commission rate.

This function is used to retrieve the maximum referral commission rate allowed by the contract. The referral commission rate determines the percentage of rewards that will be given to the referrer when a user makes a deposit.

Users can call this function to get the current maximum referral commission rate set by the contract. The returned value can be used to calculate the referral commission for a specific user's deposit.

There are no prerequisites or restrictions for calling this function. It can be called by any user at any time to retrieve the maximum referral commission rate.

getBoost

getBoost

The function getBoost is a public view function that takes two parameters: _account of type address and _pid of type uint256. It returns a uint256 value.

This function is used to retrieve the boost value for a specific account and pool. The boost value represents the additional rewards multiplier for the account in the specified pool. The boost is calculated based on the staked NFTs of the account in the pool.

To use this function, users need to provide the _account address and _pid (pool ID) as arguments. The _account address is the address of the account for which the boost value is requested. The _pid is the ID of the pool for which the boost value is requested.

The function then retrieves the boost value for the specified account and pool by calling the internal getBoost function with the provided arguments. The boost value is returned as a uint256 value.

This function is useful for users who want to check the boost value for their account in a specific pool.

  • Arguments

    NAMETYPEDESCRIPTION

    _account

    address

    The _account parameter is an address value that represents the account for which the boost value is requested. Users need to provide their account address as this argument.

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the ID of the pool for which the boost value is requested. Users need to provide the pool ID as this argument.

boosterNFT

boosterNFT

The boosterNFT function is a public view function that returns the address of the IBoosterNFT contract. This function does not take any arguments. The purpose of this function is to provide users with the address of the IBoosterNFT contract, which represents the booster NFTs used in the protocol. Users can use this function to retrieve the address of the IBoosterNFT contract and interact with it directly if needed.

devAddress

devAddress

The devAddress function is a view function that does not take any arguments and returns an address value. It is used to retrieve the address of the developer. This function does not have any prerequisites or restrictions on its usage. Users can call this function to obtain the address of the developer, which can be useful for various purposes such as contacting the developer or verifying their identity.

getContractBlock

The function getContractBlock is a public view function that does not take any arguments and returns a uint256 value. It is used to retrieve the current contract block number.

This function does not have any prerequisites or restrictions on who can call it. Any user or contract can call this function to get the current block number of the contract.

The function simply returns the current block number as a uint256 value.

Users can use this function to track the progress of the contract and perform actions based on the current block number.

getMultiplier

getMultiplier

The function getMultiplier is a pure function that takes two uint256 parameters called _from and _to and returns a uint256 value. This function is used to calculate the multiplier for a given time range.

The _from parameter represents the starting time of the range, and the _to parameter represents the ending time of the range. The function calculates the duration of the range by subtracting _from from _to.

The function then checks if the duration is less than or equal to 1 day (86400 seconds). If it is, the function returns 1. If the duration is greater than 1 day, the function calculates the number of days in the duration by dividing the duration by 86400 and rounding down to the nearest integer.

The function then calculates the multiplier by adding 1 to the number of days and multiplying it by 10. For example, if the duration is 2 days, the multiplier would be (2 + 1) * 10 = 30.

This function is useful for determining the multiplier to apply to rewards based on the duration of a time range.

This function can be used by any user at any time to calculate the multiplier for a given time range. There are no specific prerequisites or restrictions for using this function.

  • Arguments

    NAMETYPEDESCRIPTION

    _from

    uint256

    The _from parameter is a uint256 value that represents the starting time of the range. It is used to calculate the duration of the range.

    _to

    uint256

    The _to parameter is a uint256 value that represents the ending time of the range. It is used to calculate the duration of the range.

getStakedNFTDetails

The function getStakedNFTDetails is a public view function that takes two parameters: _account of type address and _pid of type uint256. It returns a tuple containing two values: an address and a uint256.

This function is used to retrieve the details of a staked NFT for a specific account and pool ID. The _account parameter represents the address of the account for which the details are being retrieved, and the _pid parameter represents the pool ID of the staked NFT.

The function accesses the _depositedNFT mapping using the _account and _pid parameters as keys. It retrieves the nftAddress and tokenId values stored in the mapping for the specified account and pool ID.

The function then returns a tuple containing the retrieved nftAddress and tokenId values as the result.

Users can use this function to obtain the address and token ID of a staked NFT for a specific account and pool ID.

  • NAMETYPEDESCRIPTION

    _account

    address

    The _account parameter is of type address and represents the address of the account for which the staked NFT details are being retrieved.

    _pid

    uint256

    The _pid parameter is of type uint256 and represents the pool ID of the staked NFT for which the details are being retrieved.

isPrivatePoolWhitelist

The function isPrivatePoolWhitelist is a public view function that takes an address parameter called _address and returns a bool value. It is used to check if a given address is whitelisted for private pools.

The function first checks if the _address is present in the private pool whitelist mapping. If the _address is present, it returns true, indicating that the address is whitelisted for private pools. If the _address is not present, it returns false, indicating that the address is not whitelisted for private pools.

This function is useful for determining whether a specific address has permission to access and participate in private pools. Users can call this function to check if their address is whitelisted before attempting to interact with private pools.

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    The _address parameter is an Ethereum address that represents the address to check for whitelist status. Users can pass their own address or any other address to check if it is whitelisted for private pools.

isWhitelist

isWhitelist

The function isWhitelist is a public view function that takes an address parameter called _address and returns a bool value. It is used to check if a given address is whitelisted. The function first checks if the _address is whitelisted for the main pool by calling the isWhitelist function. If the _address is whitelisted for the main pool, the function returns true. If the _address is not whitelisted for the main pool, the function checks if the _address is whitelisted for any private pools by calling the isPrivatePoolWhitelist function. If the _address is whitelisted for any private pools, the function returns true. If the _address is not whitelisted for any private pools, the function checks if the _address is whitelisted for any NFTs by calling the isWhitelistedNFT function. If the _address is whitelisted for any NFTs, the function returns true. If the _address is not whitelisted for any NFTs, the function returns false. This function is useful for checking if a given address is allowed to perform certain actions or access certain features within the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    The _address parameter is an Ethereum address that represents the address to check for whitelist status.

isWhitelistedNFT

The function isWhitelistedNFT is a public view function that takes an address parameter called _address and returns a bool value. It is used to check if a specific address is whitelisted for NFT staking.

The function first checks if the _address is whitelisted by calling the isWhitelist function with the _address as the argument. If the _address is whitelisted, the function then checks if the _address is whitelisted for NFT staking by calling the isWhitelistedNFT function with the _address as the argument.

The function returns the result of the isWhitelistedNFT function, indicating whether the _address is whitelisted for NFT staking or not. The result is a bool value, true if the _address is whitelisted for NFT staking and false otherwise.

This function is useful for checking if a specific address is allowed to stake NFTs in the contract. Users can use this function to verify their eligibility for NFT staking before calling the stakeNFT function.

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    The _address parameter is an Ethereum address that represents the address to check for whitelisting. Users can pass their own address or any other address to check if it is whitelisted for NFT staking.

lpTokenAmount

The function lpTokenAmount is a public view function that takes a uint256 parameter called _pid and returns a uint256 value. It is used to retrieve the amount of LP tokens staked by a user in a specific pool.

The function first checks the poolInfo mapping to get the pool information for the given _pid. It then calls the userInfo function with the _pid and the user's address to retrieve the user's staked amount and reward debt for that pool.

The function returns the staked amount of LP tokens for the user in the specified pool as a uint256 value.

This function is useful for users who want to check the amount of LP tokens they have staked in a specific pool.

nftBoostRate

The function nftBoostRate is a public view function that takes a uint8 parameter called nftType and returns a uint256 value. It is used to retrieve the boost rate for a specific NFT type. The boost rate determines the multiplier applied to the rewards earned by staking NFTs of a particular type in the pool. The function first checks if the caller is whitelisted or the owner of the contract. If not, it reverts with an error message. The function then retrieves the boost rate for the specified nftType from the internal mapping. If the boost rate is not found (i.e., it is zero), the function reverts with an error message. The function returns the boost rate as a uint256 value. Users can use this function to determine the boost rate for a specific NFT type before staking their NFTs in the pool.

The caller must be whitelisted or the owner of the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    input (uint8)

    uint8

    Boost rate for NFT category calculated in 1% = 100

owner

owner

The function owner is a view function that does not take any arguments. It returns the address of the owner of the contract. This function is used to retrieve the address of the owner of the contract. It does not modify any state variables and can be called by anyone. The function returns the address of the owner as an output value. Users can use this function to verify the current owner of the contract and ensure that the contract is being managed by the intended owner.

pendingToken

pendingToken

The function pendingToken is a public view function that takes two parameters: _pid of type uint256 and _user of type address. It returns a uint256 value.

This function is used to calculate the pending TOKEN rewards for a specific user in a specific pool. The user must provide the pool ID (_pid) and their address (_user) as arguments.

The function first retrieves the pool information (PoolInfo) and user information (UserInfo) from the respective storage mappings using the provided _pid and _user.

Next, it calculates the accumulated TOKEN rewards per share (accTokenPerShare) for the pool. If the current block timestamp is greater than the last reward block of the pool and the LP supply (lpSupply) is not zero, it calculates the tokenReward based on the multiplier, tokenPerBlock, pool allocation point, and total allocation point. It then updates the accTokenPerShare by adding the calculated tokenReward divided by the LP supply.

Finally, the function calculates the pending TOKEN rewards for the user by multiplying their LP token amount (user.amount) by the accTokenPerShare and dividing by 1e18. It subtracts the user's reward debt (user.rewardDebt) from the calculated value.

The function returns the calculated pending TOKEN rewards for the user.

  • NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the pool ID. It is used to identify the specific pool for which the pending TOKEN rewards are being calculated.

    _user

    address

    The _user parameter is an address value that represents the user's address. It is used to identify the specific user for whom the pending TOKEN rewards are being calculated.

poolInfo

poolInfo

The function poolInfo is a public view function that takes a uint256 parameter called _pid and returns multiple values including the address of the LP token, the allocation point, the last reward block, the accumulated token per share, the deposit fee, and whether the pool is a private pool or not. This function is used to retrieve information about a specific pool identified by its _pid. The function first checks if the _pid is valid by accessing the poolLength function to get the total number of pools. If the _pid is greater than or equal to the pool length, the function will revert with an error message. If the _pid is valid, the function retrieves the pool information from the poolInfo array using the _pid as the index. The function returns the LP token address, the allocation point, the last reward block, the accumulated token per share, the deposit fee, and whether the pool is a private pool or not.

This function can be called by any user at any time to retrieve information about a specific pool. There are no specific prerequisites or restrictions for using this function.

  • Arguments

    NAMETYPEDESCRIPTION

    input (uint256)

    uint256

    PID of pool you want to check details

poolLength

poolLength

The function poolLength is a public view function that does not take any arguments and returns a uint256 value. It is used to get the length of the poolInfo array, which represents the number of pools in the contract. The function retrieves the length of the poolInfo array by calling the poolLength function on the contract. The length is stored in a uint256 variable and returned as the output of the function. Users can use this function to determine the number of pools available in the contract and iterate over the poolInfo array to access information about each pool.

referral

referral

The function referral is a public view function that returns the address of the referral. It does not take any arguments. This function is used to retrieve the address of the referral, which is the address that users can use to refer others to the platform. The referral address is set using the setReferralAddress function, which can only be called by the contract owner. Users can use this function to get the referral address and share it with others to earn referral commissions. The function returns the address of the referral as an output.

referralCommissionRate

referralCommissionRate

The function referralCommissionRate is a public view function that does not take any arguments and returns a uint16 value. It is used to retrieve the current referral commission rate.

The referral commission rate is a percentage value that determines the amount of commission earned by the referrer when a user makes a deposit. The higher the referral commission rate, the more commission the referrer will earn.

This function is called by users who want to know the current referral commission rate before making a deposit. It provides transparency and allows users to make informed decisions about their investments.

The function does not modify any state variables and is marked as view, indicating that it does not modify the blockchain state.

The function returns the referral commission rate as a uint16 value, which represents a percentage value between 0 and 65535 (inclusive). For example, a return value of 50000 represents a referral commission rate of 50%.

startUnixTime

tartUnixTime

The function startUnixTime is a view function that returns a uint256 value. It does not take any arguments. The purpose of this function is to retrieve the startUnixTime value, which represents the Unix timestamp when the contract was deployed or when the start time of the contract's functionality began. The function simply returns the startUnixTime value stored in the contract. Users can use this function to get the startUnixTime value for various purposes, such as calculating the duration of the contract's functionality or determining the eligibility of certain actions based on the start time.

token

The function token is a public view function that returns the address of the token contract. It does not take any arguments. This function is used to retrieve the address of the token contract that is associated with the current contract. Users can call this function to obtain the address of the token contract and interact with it directly. The function simply returns the address of the token contract as a result.

tokenPerBlock

The function tokenPerBlock is a public view function that does not take any arguments and returns a uint256 value. It is a getter function for the tokenPerBlock variable. The purpose of this function is to retrieve the current emission rate of tokens per block. The function simply returns the value of the tokenPerBlock variable, which represents the number of tokens that are emitted as rewards per block. Users can use this function to check the current emission rate of tokens per block in the contract.

totalAllocPoint

totalAllocPoint

The function totalAllocPoint is a public view function that does not take any arguments and returns a uint256 value. It is a getter function for the totalAllocPoint state variable. The totalAllocPoint state variable represents the total allocation points of all pools in the contract. Allocation points determine the share of rewards that each pool receives. This function is used by users and other contracts to retrieve the current value of totalAllocPoint. By calling this function, users can get information about the total allocation points in the contract, which can be used to calculate the relative share of rewards for each pool. There are no prerequisites or restrictions for using this function.

userInfo

userInfo

The function userInfo is a view function that takes two parameters: uint256 pid and address user. It returns two uint256 values: amount and rewardDebt. This function is used to retrieve information about a user's deposit in a specific pool. The pid parameter represents the pool ID, which is an index used to identify a specific pool. The user parameter represents the address of the user whose information is being retrieved. The function first checks if the user is whitelisted by calling the whitelistAll function. If the user is not whitelisted, the function returns 0 for both amount and rewardDebt. If the user is whitelisted, the function retrieves the user's deposit amount and reward debt from the poolInfo mapping using the pid and user parameters. The deposit amount represents the number of tokens the user has deposited in the pool, while the reward debt represents the amount of rewards the user has already claimed. The function returns the amount and rewardDebt values as the output.

The user must be whitelisted in order to retrieve their information. This can be checked by calling the whitelistAll function.

  • Arguments

    NAMETYPEDESCRIPTION

    input (uint256)

    uint256

    Farm PID

    input (address)

    address

    User Address

whitelistAll

whitelistAll

The function whitelistAll is a public view function that does not take any arguments and returns a bool value. It is used to check if all addresses are whitelisted.

The function does not modify any state variables and does not require any prerequisites or conditions to be met. It simply returns the value of a bool variable that indicates whether all addresses are whitelisted or not.

Users can call this function to check if all addresses have been whitelisted. If the function returns true, it means that all addresses are whitelisted. If the function returns false, it means that there are addresses that are not whitelisted.

This function is useful for verifying the status of the whitelist and determining if all addresses have been granted access or not.

Write Functions

add

add

The function add is a public function that can only be called by the owner. It takes five parameters:

  1. _allocPoint (uint256): The allocation point for the LP token in the pool. This determines the share of tokens that will be distributed to this pool.

  2. _lpToken (address): The address of the LP token contract that will be added to the pool.

  3. _depositFee (uint256): The deposit fee for the pool. This fee is a percentage of the LP tokens deposited by users and cannot be greater than 10% (1000 basis points).

  4. _isPrivatePool (bool): A boolean value indicating whether the pool is a private pool or not.

  5. _withUpdate (bool): A boolean value indicating whether to update all pools before adding the new pool.

The function first checks if the deposit fee is less than or equal to 10%. If not, it reverts with an error message.

If _withUpdate is true, it calls the massUpdatePools function to update all pools.

It then calculates the last reward block based on the current block timestamp and the startUnixTime.

The total allocation point is increased by the _allocPoint.

Finally, a new PoolInfo struct is added to the poolInfo array with the provided parameters and initial values for other variables.

The function can only be called by the owner.

  • Arguments

    NAMETYPEDESCRIPTION

    _allocPoint

    uint256

    The allocation point for the LP token in the pool. This determines the share of tokens that will be distributed to this pool.

    _lpToken

    address

    The address of the LP token contract that will be added to the pool.

    _depositFee

    uint256

    The deposit fee for the pool. This fee is a percentage of the LP tokens deposited by users and cannot be greater than 10% (1000 basis points).

    _isPrivatePool

    bool

    A boolean value indicating whether the pool is a private pool or not.

    _withUpdate

    bool

    A boolean value indicating whether to update all pools before adding the new pool.

deposit

deposit

The function deposit is a non-payable function that allows users to deposit a specified amount of tokens into a specific pool. The function takes three parameters:

  1. _pid (uint256): This parameter represents the pool ID of the pool where the tokens will be deposited. Users need to provide the correct pool ID to ensure that the tokens are deposited into the desired pool.

  2. _amount (uint256): This parameter represents the amount of tokens that the user wants to deposit into the pool. Users need to provide a valid amount of tokens to be deposited.

  3. _referrer (address): This parameter represents the address of the referrer. It is an optional parameter that allows users to specify the address of the person who referred them to the platform. If a user doesn't have a referrer, they can pass the address 0x0.

Users can use this function to deposit their tokens into a specific pool and potentially earn rewards based on their deposited amount and the pool's reward mechanism.

Users need to have the tokens they want to deposit in their wallet. They also need to know the correct pool ID where they want to deposit the tokens. Optionally, if they have a referrer, they need to know the address of the referrer.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the pool ID of the pool where the tokens will be deposited. Users need to provide the correct pool ID to ensure that the tokens are deposited into the desired pool.

    _amount

    uint256

    The _amount parameter is a uint256 value that represents the amount of tokens that the user wants to deposit into the pool. Users need to provide a valid amount of tokens to be deposited.

    _referrer

    address

    The _referrer parameter is an address value that represents the address of the referrer. It is an optional parameter that allows users to specify the address of the person who referred them to the platform. If a user doesn't have a referrer, they can pass the address 0x0.

depositNFT

depositNFT

The function depositNFT is a public function that allows users to deposit their NFTs into a specific pool. It takes three parameters:

  1. _nft: This is the address of the NFT contract that the user wants to deposit. The user must have ownership of the NFT in order to deposit it.

  2. _tokenId: This is the unique identifier of the NFT that the user wants to deposit. The user must own the NFT with this specific tokenId in order to deposit it.

  3. _pid: This is the pool ID of the pool where the user wants to deposit their NFT. The user can only deposit their NFT into a whitelisted pool.

Before depositing the NFT, the function performs several checks and validations. It checks if the NFT is whitelisted, meaning it is an approved NFT that can be deposited. It also checks if the user is the owner of the specified NFT. If any of these checks fail, the function will revert with an error message.

After the checks, the function updates the pool information and calculates the pending rewards for the user. If the user has any pending rewards, they are transferred to the user's address.

Then, the function transfers the ownership of the NFT from the user to the contract address. It also updates the NFT details for the user and the specified pool.

This function is used by users to deposit their NFTs into the specified pool and boost the pool's rewards.

  • Arguments

    NAMETYPEDESCRIPTION

    _nft

    address

    The _nft parameter is the address of the NFT contract that the user wants to deposit. The user must have ownership of the NFT in order to deposit it.

    _tokenId

    uint256

    The _tokenId parameter is the unique identifier of the NFT that the user wants to deposit. The user must own the NFT with this specific tokenId in order to deposit it.

    _pid

    uint256

    The _pid parameter is the pool ID of the pool where the user wants to deposit their NFT. The user can only deposit their NFT into a whitelisted pool.

emergencyWithdraw

emergencyWithdraw

The function emergencyWithdraw is a non-payable function that takes a uint256 parameter called _pid. This function allows users to emergency withdraw their funds from the specified pool identified by _pid.

Users can use this function when they want to immediately withdraw their funds from the pool without waiting for the normal withdrawal process. This function is designed to handle emergency situations where users need to quickly access their funds.

The function does not have any outputs and is marked as non-payable, meaning it does not accept any value transfers.

It is important to note that this function does not perform any checks or validations on the user's request. It directly withdraws the funds from the pool without considering any conditions or restrictions.

Users should exercise caution when using this function as it bypasses any normal withdrawal process and may have potential risks or consequences.

This function does not have any specific prerequisites or restrictions. Users can directly call this function to emergency withdraw their funds from the specified pool identified by _pid.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the pool ID of the pool from which the user wants to emergency withdraw their funds. The _pid is used to identify the specific pool in which the user has deposited their funds.

flipWhitelistAll

flipWhitelistAll

The function flipWhitelistAll is a public function that does not take any arguments. It is restricted to be called only by the owner of the contract. This function is used to flip the value of the whitelistAll variable. If whitelistAll is currently true, calling this function will set it to false, and vice versa. Users can use this function to toggle the whitelistAll variable, which determines whether all addresses are whitelisted or not. By flipping the whitelistAll variable, the owner can enable or disable the whitelist functionality for all addresses in the contract.

harvestAll

harvestAll

The function harvestAll is a public function that takes an array of uint256 values called _pids as an argument. It allows users to harvest rewards from multiple farms by specifying the pool IDs (_pids) they want to harvest from.

The function iterates over each pool ID in the _pids array and performs the following actions:1. Checks if the pool ID is valid by comparing it with the length of the poolInfo array. 2. Retrieves the user information (amount and rewardDebt) for the specified pool ID and the caller's address.

  1. If the user has staked an amount greater than 0, the function proceeds to the next steps.

  2. Updates the pool information for the specified pool ID.

  3. Calculates the pending rewards for the user by multiplying the user's staked amount with the pool's accTokenPerShare and dividing it by 1e18. Then subtracts the user's rewardDebt from the calculated pending rewards.

  4. If the pending rewards are greater than 0, the function transfers the pending rewards to the caller's address using the safeTokenTransfer function.

  5. Updates the user's rewardDebt to the new value calculated in step 5.

  6. Emits a Harvest event with the caller's address, the pool ID, and the amount of rewards harvested.

Users can use this function to claim their rewards from multiple farms at once by providing the pool IDs they want to harvest from in the _pids array.

The user must have staked an amount greater than 0 in the farms they want to harvest rewards from.

  • Arguments

    NAMETYPEDESCRIPTION

    _pids

    uint256[]

    The _pids parameter is an array of uint256 values that represents the pool IDs of the farms from which the user wants to harvest rewards. Each pool ID corresponds to a specific farm in the poolInfo array.

massUpdatePools

massUpdatePools

The function massUpdatePools is a public function with no arguments and no return value. It is a non-payable function that can be called by anyone. The purpose of this function is to update all the pools in the contract. It iterates over all the pools and calls the updatePool function for each pool. The updatePool function updates the pool's reward allocation and calculates the pending rewards for the users who have staked their tokens in the pool. By calling the massUpdatePools function, users can ensure that all the pools are up to date and that they have the most accurate information about their pending rewards. This function is useful when there are multiple pools in the contract and users want to update all the pools at once instead of calling the updatePool function individually for each pool.

renounceOwnership

The function renounceOwnership is a non-payable function with no arguments. It is a public function that allows the current owner of the contract to renounce their ownership and transfer the ownership to the zero address (0x0000000000000000000000000000000000000000).

This function can only be called by the current owner of the contract. It is typically used when the current owner wants to permanently relinquish their control and ownership of the contract, effectively making it ownerless.

Upon successful execution of this function, the ownership of the contract will be transferred to the zero address, meaning that no one will have ownership or control over the contract anymore.

It is important to note that once the ownership is renounced, it cannot be reversed or transferred back to any address. This function should be used with caution and only when the current owner is certain about relinquishing their ownership rights.

set

set

The function set is a public function that allows the owner of the contract to set the allocation point for a specific pool. It takes three parameters:

  1. _pid (uint256): The ID of the pool for which the allocation point is being set.

  2. _allocPoint (uint256): The new allocation point for the pool.

  3. _withUpdate (bool): A flag indicating whether or not to update all pools before setting the allocation point.

The function first checks if the caller is the owner of the contract. If not, the function reverts.

If _withUpdate is true, the function calls the internal function massUpdatePools to update all pools before setting the allocation point.

The function then updates the allocation point for the specified pool by calling the internal function updatePool with the _pid and _allocPoint parameters.

This function is used by the owner of the contract to adjust the allocation points for different pools in order to distribute rewards among them.

The caller must be the owner of the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The ID of the pool for which the allocation point is being set.

    _allocPoint

    uint256

    The new allocation point for the pool.

    _withUpdate

    bool

    A flag indicating whether or not to update all pools before setting the allocation point.

setBoosterNFT

setBoosterNFT

The function setBoosterNFT is a public function that takes an address parameter called _booterNFT. It can only be called by the contract owner. The purpose of this function is to set the address of the boosterNFT contract. The function first checks if the _booterNFT address is valid (not equal to address(0x0)). If it is valid, the function sets the boosterNFT variable to an instance of the IBoosterNFT contract using the _booterNFT address. This function is used to configure the boosterNFT contract address within the current contract. It allows the contract to interact with the boosterNFT contract and access its functions and data.

onlyOwnerUsers can call this function to set the address of the boosterNFT contract within the current contract. Only the contract owner can call this function.

  • Arguments

    NAMETYPEDESCRIPTION

    _booterNFT

    address

    The _booterNFT parameter is an address value that represents the address of the boosterNFT contract. It should be a valid address, not equal to address(0x0).

setDepositFee

setDepositFee

The function setDepositFee is a public function that allows the owner of the contract to set the deposit fee for a specific pool identified by the _pid parameter. The function takes two parameters: _pid of type uint256 and _depositFee of type uint256.

The _pid parameter represents the pool ID of the pool for which the deposit fee is being set. The _depositFee parameter represents the new deposit fee to be set for the pool. The deposit fee must be less than or equal to 10% (1000 basis points).

The function first checks if the deposit fee is within the allowed range by using the require statement. If the deposit fee is greater than 10%, the function reverts with an error message.

If the deposit fee is valid, the function updates the deposit fee of the pool identified by the _pid parameter with the new _depositFee value.

This function can only be called by the owner of the contract.

The function can only be called by the owner of the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is of type uint256 and represents the pool ID of the pool for which the deposit fee is being set.

    _depositFee

    uint256

    The _depositFee parameter is of type uint256 and represents the new deposit fee to be set for the pool. The deposit fee must be less than or equal to 10% (1000 basis points).

setDevAddress

setDevAddress

The function setDevAddress is a public non-payable function that takes an address parameter called _devAddress. It is a setter function used to set the devAddress variable in the contract. The purpose of this function is to update the devAddress variable with a new address provided by the user. The function first checks if the _devAddress parameter is not equal to the zero address (0x0) using the require statement. If the _devAddress is valid, the devAddress variable is updated with the new address. This function is used by the owner of the contract to change the devAddress, which is typically the address of the developer or the team behind the contract.

The function can only be called by the owner of the contract (onlyOwner modifier).

  • Arguments

    NAMETYPEDESCRIPTION

    _devAddress

    address

    The _devAddress parameter is an address value that represents the new devAddress to be set in the contract. It should be a valid address and not equal to the zero address (0x0).

setNftBoostRate

setNftBoostRate

The function setNftBoostRate is a public function that allows the contract owner to set the boost rate for a specific NFT type. It takes two parameters:

  1. _nftType (uint8): This parameter represents the NFT type for which the boost rate is being set.

  2. _rate (uint256): This parameter represents the boost rate that will be set for the specified NFT type.

The function first checks if the caller of the function is the contract owner by using the onlyOwner modifier. If the caller is not the owner, the function will revert.

If the caller is the owner, the function sets the boost rate for the specified NFT type by assigning the _rate value to the nftBoostRate[_nftType] mapping.

After setting the boost rate, the function emits an UpdateNFTBoostRate event to notify listeners about the update.

This function is used by the contract owner to set the boost rate for different NFT types, which can affect the behavior or rewards of the NFTs in the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _nftType

    uint8

    NFT category

    _rate

    uint256

    Boost power 1% = 100

setReferralAddress

setReferralAddress

The function setReferralAddress is a public function that takes an address parameter called _referral. It is a setter function used to set the referral address for the contract.

The function is accessible to all users of the contract.

The function sets the referral address by assigning the value of _referral to the referral variable.

This function is used to update the referral address, which is used for referral purposes within the contract. Users can call this function to set their referral address and participate in the referral program of the contract.

Prerequisite: There is no prerequisite mentioned in the provided context.

  • Arguments

    NAMETYPEDESCRIPTION

    _referral

    address

    The _referral parameter is an address value that represents the referral address to be set. Users can pass their desired referral address as an argument to this function.

setReferralCommissionRate

setReferralCommissionRate

The function setReferralCommissionRate is a non-payable function that takes a uint16 parameter called _referralCommissionRate. It is a setter function used to set the referral commission rate for the contract.

The function can be called by anyone and does not require any specific prerequisites or permissions.

The function sets the referral commission rate for the contract to the value specified by the _referralCommissionRate parameter. The referral commission rate represents the percentage of the deposit fee that will be given as a commission to the referrer when a user makes a deposit.

This function is used to adjust the referral commission rate and can be called at any time to update the rate.

The function does not return any value.

  • Arguments

    NAMETYPEDESCRIPTION

    _referralCommissionRate

    uint16

    The _referralCommissionRate parameter is a uint16 value that represents the referral commission rate to be set for the contract. The value should be between 0 and the maximum referral commission rate defined by the contract.

toggleNftWhitelist

toggleNftWhitelist

The function toggleNftWhitelist is an external function that takes two parameters: _address of type address and _toggle of type bool. It is a function that can only be called by the contract owner. The purpose of this function is to toggle the whitelist status of a given address for NFTs. The function first checks if the current whitelist status of the given address is different from the desired toggle value. If they are the same, meaning the address is already in the toggled state, the function reverts with the error message 'already in Toggled State'. If the whitelist status needs to be toggled, the function updates the whitelist status of the given address with the new toggle value. Finally, the function emits the ToggleNftWhitelisted event with the updated address and toggle value. Users can call this function to toggle the whitelist status of a specific address for NFTs.

The function can only be called by the contract owner.

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    The _address parameter is of type address and represents the address for which the whitelist status needs to be toggled.

    _toggle

    bool

    The _toggle parameter is of type bool and represents the desired whitelist status for the given address. If _toggle is true, it means the address should be whitelisted for NFTs. If _toggle is false, it means the address should be removed from the whitelist for NFTs.

togglePrivatePoolWhitelist

togglePrivatePoolWhitelist

The function togglePrivatePoolWhitelist is an external function that takes two parameters: _address of type address and _toggle of type bool. This function can only be called by the contract owner (onlyOwner). The purpose of this function is to toggle the whitelist status of a given address for the private pool.

The function first checks if the current whitelist status of the given address for the private pool is different from the desired toggle value (_toggle). If they are the same, it means the address is already in the toggled state, and the function reverts with the error message 'already in Toggled State'.

If the current whitelist status is different from the desired toggle value, the function updates the whitelist status of the given address for both the private pool (_whitelistPrivatePool) and the general whitelist (_whitelist) to the desired toggle value (_toggle).

Finally, the function emits the event TogglePrivatePoolWhitelisted with the updated address and toggle value.

This function is used by the contract owner to toggle the whitelist status of a specific address for the private pool, allowing or disallowing access to the private pool for the given address.

This function can only be called by the contract owner (onlyOwner).

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    The _address parameter is of type address and represents the address for which the whitelist status will be toggled. This address can be any valid Ethereum address.

    _toggle

    bool

    The _toggle parameter is of type bool and represents the desired whitelist status for the given address. If _toggle is true, it means the address will be whitelisted, allowing access to the private pool. If _toggle is false, it means the address will be removed from the whitelist, disallowing access to the private pool.

toggleWhitelist

toggleWhitelist

The function toggleWhitelist is an external function that takes two parameters: _address of type address and _toggle of type bool. It is a function that can only be called by the contract owner.

The purpose of this function is to toggle the whitelist status of a given address. The function first checks if the current whitelist status of the address is different from the desired toggle value. If they are the same, it means that the address is already in the toggled state and the function reverts with an error message.

If the current whitelist status is different from the desired toggle value, the function updates the whitelist status of the address to the desired toggle value. It then emits an event called ToggleWhitelisted, passing the updated address and toggle value as parameters.

This function is used by the contract owner to manage the whitelist status of addresses. By toggling the whitelist status, the contract owner can control whether an address is allowed or disallowed to perform certain actions within the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _address

    address

    address of sc to whitelist

    _toggle

    bool

    true or false

transferOwnership

transferOwnership

The function transferOwnership is an internal function that takes an address parameter called newOwner. It is used to transfer the ownership of the contract to a new account. The function first checks if the newOwner address is not the zero address, which means it is a valid address. If the newOwner address is valid, the function emits an OwnershipTransferred event, indicating the transfer of ownership from the current owner (_owner) to the new owner (newOwner). Finally, the function updates the _owner variable with the newOwner address. This function is used internally and can only be called by other functions within the contract.

This function can only be called by other functions within the contract. There is no specific prerequisite for using this function.

  • Arguments

    NAMETYPEDESCRIPTION

    newOwner

    address

    The newOwner parameter is an address value that represents the account to which the ownership of the contract will be transferred. It must be a valid Ethereum address.

updateEmissionRate

updateEmissionRate

The function updateEmissionRate is a public function that takes a uint256 parameter called _tokenPerBlock. It is a setter function used to update the emission rate of tokens per block.

The function first calls the massUpdatePools function to update all the pools before changing the emission rate. Then, it assigns the value of _tokenPerBlock to the tokenPerBlock variable, which represents the new emission rate.

After updating the emission rate, the function emits an UpdateEmissionRate event, providing the address of the user who called the function and the new tokenPerBlock value.

This function can be used by the owner of the contract to adjust the rate at which tokens are generated per block. It is important to note that only the owner of the contract can call this function, as indicated by the onlyOwner modifier.

The function can only be called by the owner of the contract, as indicated by the onlyOwner modifier.

  • Arguments

    NAMETYPEDESCRIPTION

    _tokenPerBlock

    uint256

    The _tokenPerBlock parameter is a uint256 value that represents the new emission rate of tokens per block. It determines the amount of tokens that will be generated and distributed to the pools in each block.

updatePool

updatePool

The function updatePool is a non-payable function that takes a uint256 parameter called _pid. It is a public function that can be called by anyone. The purpose of this function is to update the pool information for a specific pool identified by _pid. The function first checks if the caller is the owner of the contract by comparing the msg.sender address with the owner address stored in the contract. If the caller is the owner, the function updates the pool information by calling the internal function _updatePool with the _pid parameter. The _updatePool function updates the pool's tokenPerBlock, lastRewardBlock, and accTokenPerShare values based on the current block number and the number of tokens minted since the last update. The function does not return any value. Users can use this function to update the pool information, such as the tokenPerBlock rate, to adjust the rewards for the pool.

The caller must be the owner of the contract.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the pool ID of the pool to be updated. Each pool in the contract is identified by a unique _pid.

withdraw

withdraw

The function withdraw is a non-payable function that allows users to withdraw a specified amount of tokens from a specific pool. The function takes two arguments:

  1. _pid (uint256): This argument represents the pool ID of the pool from which the user wants to withdraw tokens. The pool ID is an unsigned integer value.

  2. _amount (uint256): This argument represents the amount of tokens that the user wants to withdraw from the specified pool. The amount is an unsigned integer value.

The function does not have any prerequisites or restrictions, and any user can call this function to withdraw tokens from a pool. The function does not return any value.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is a uint256 value that represents the pool ID of the pool from which the user wants to withdraw tokens. The pool ID is an unsigned integer value.

    _amount

    uint256

    The _amount parameter is a uint256 value that represents the amount of tokens that the user wants to withdraw from the specified pool. The amount is an unsigned integer value.

withdrawNFT

withdrawNFT

The function withdrawNFT is a non-payable function that allows a user to withdraw their staked NFT from a specific pool. The function takes one argument, _pid, which is of type uint256 and represents the pool ID.

Before calling this function, the user must have previously staked an NFT in the specified pool using the function stakeNFT. The user can obtain the pool ID by calling the function getStakedNFTDetails, which returns the pool ID associated with the user's staked NFT.

When the function is called, it first checks if the user has a staked NFT in the specified pool. If the user does not have a staked NFT, the function reverts with an error message.

If the user has a staked NFT, the function proceeds to remove the NFT from the pool. This involves updating the user's staked NFT details and reducing the total staked NFT count for the pool.

After successfully withdrawing the NFT, the function emits an event to notify the user and any external applications about the withdrawal.

This function is useful for users who want to retrieve their staked NFT from a pool and potentially use it elsewhere or sell it on a marketplace.

The user must have previously staked an NFT in the specified pool using the stakeNFT function.

  • Arguments

    NAMETYPEDESCRIPTION

    _pid

    uint256

    The _pid parameter is of type uint256 and represents the pool ID from which the user wants to withdraw their staked NFT. The pool ID is obtained by calling the getStakedNFTDetails function.

Last updated