deposit
, withdraw
&& withdrawAll
, withdraw reward claim
&& claimAll
. deposit
, you need to pass in the address of the pledged token, and the number of tokens pledged by the user. Before calling it, make sure that the user's pledged tokens are authorized to the mining contract, and that the mining contract internally transfers the pledged tokens from the user's account to the mining contract via the transferFrom
method. When deposit is called, the contract will also automatically withdraw and transfer the user's currently earned rewards to the user's account.withdraw
&& withdrawAll
. For the withdraw
function, you need to pass the token address and specify the number of tokens to be withdrawn, while for the withdrawAll
function, you only need to pass the token address to be withdrawn, and the contract will internally withdraw all the tokens pledged by the current user to The contract will withdraw all the tokens pledged by the current user to his account. Also, by calling these two functions, the contract will automatically withdraw and transfer the current rewards to the user's account.claim
&& claimAll
.The former requires passing in the address of the pledged token from which the reward tokens are extracted. And the latter will extract all the mining rewards that the current user has participated in, but this function will consume more gas, please use it carefully.getUserLpBalance
to get the number of tokens pledged by the user, which requires passing in the pledged token address as well as the user address.getPendingReward
&& getAllPendingReward
, the former needs to pass in the pledged token address and the user address to get the number of user rewards corresponding to the current pledge. The latter only needs to pass in the user's address, and returns the total number of tokens rewarded for all mining projects the current user has participated in.deposit
, withdraw
, withdraw mining rewards claimReward
&& claimAllRewards.
deposit
, the parameter passed in is the number of tokens pledged, while ensuring that the user's tokens are authorized to the current mining contract before pledging, and the mining contract internally transfers the user's pledged tokens to the mining contract by calling the transferFrom
function.withdraw
pledge token function, pass in the number of pledge tokens to be withdrawnclaimReward
&& claimAllRewards
functions, the former needs to pass in the corresponding serial number of the reward tokens, and only the corresponding reward tokens will be extracted; the latter will extract all the reward tokens mined.getPendingReward
&& getPendingRewardByToken
, the former requires passing in the user address and the corresponding reward token serial number, the latter passes in the user address and the reward token address.