Documentation
General overview of the most important smart-contract interactions.
The two most important smart-contracts that you will be interacting with are:
LockedStaking.sol (Mainnet on-chain example, Hololoot Locked #1 Pool)
FlexibleStaking.sol (Mainnet on-chain example, Hololoot Flexible Pool)
Please note that some functions differ between both smart contracts.
LockedStaking.sol
getPlansLength()
Returns the length of the _plans
array.
factory()
Returns the address of the factory contract.
getPlans()
Returns an array of StakingPlan
structs representing the available staking plans.
getPlan()
Returns the StakingPlan
struct for a specific plan ID. Params:
uint256 planId - ID of the plan
stakingPool()
Returns the StakingPool
struct containing information about the staking pool.
stakesInfoOf()
Returns an array of UserStake
structs representing the stake information for a specific staker. Params:
address staker - address of a staker
stakeInfoOf()
Returns the UserStake
struct for a specific staker and plan ID. Params:
address staker - address of a staker
uint256 planId - ID of a plan
stake()
Stakes tokens for a specific staking plan. Params:
uint256 amount - amount to stake
uint256 stakingPlanId - ID of a plan
unstake()
Unstakes tokens from a specific staking plan. Params:
uint256 stakingPlanId - ID of a plan
unstakeWithPenatly()
Unstakes tokens from a specific staking plan before the end of the staking period, with a penalty. Params:
uint256 stakingPlanId - ID of a plan
claimUnusedRewards()
Sends unused reward tokens back to the contract owner.
FlexibleStaking.sol
extendStakingTime()
This function allows the creator of the contract to extend the staking period by specifying a new end date. The creator needs to provide additional staking tokens to cover the extended period. Params:
uint256 _newEndDate - new date when staking will end
deposit()
Any user can deposit a specified amount of tokens into the contract for staking. The tokens must be transferred to the contract address. Params:
uint256 _amount - amount of tokens to deposit
withdraw()
Allows users to withdraw a specific amount of their staked tokens from the contract. The function also harvests any pending rewards before withdrawal.
uint256 _amount - amount of tokens to withdraw
claimRewards()
Enables any user to claim their accumulated staking rewards from the contract.
checkRewards()
Allows users to check the amount of unharvested rewards associated with their staked tokens. Params:
address _staker - address of a given staker
getSummary()
Returns a summary of key contract data, including reward tokens per second, the total amount of staked tokens, accumulated rewards per share, last reward block timestamp, start timestamp, end timestamp and the address of the staked token.
emergencyWithdraw()
Allows the protocol owner to withdraw a specified amount of tokens from the contract to their address in emergency situations.
address _tokenAddress - address of the token to withraw
uint256 _amount - amount to withdraw
If you have any questions, please reach out to techsupport@earn.network. Additionally, we can create a staking contract with a custom token on a selected testnet (Sepolia, BNB Testnet). In such scenario, you will be able to test it.
Last updated