forked from Fantom-foundation/fantom-sfc
-
Notifications
You must be signed in to change notification settings - Fork 0
Reward calls reference
Egor Lysenko edited this page Dec 15, 2020
·
5 revisions
Claim earned rewards.
Reward for a non-locked stake is 30% (base rate) of full reward for a locked stake.
-
maxEpochs
is maximum number of epochs to claim rewards for (in one call). If you have rewards for many epochs, call method multiple times until all rewards are claimed. If not sure, use 100.
Rewards may be claimed in either non-compound or compound mode:
- Rewards claiming in non-compound mode transfers the reward to caller's account.
- Rewards claiming in compound mode stakes the claimed reward, increasing delegation/validator stake. Reward may be higher than in non-compound mode, because it is estimated as a compound reward. Compound reward us estimated by incrementing stake after every calculated epoch reward.
For delegation in non-compound mode:
// check you have rewards to claim:
sfcc.calcDelegationRewards("0xAddress", stakerID, 0, maxEpochs) // returns: rewards amount, first claimed epoch, last claimed epoch
// claim rewards:
sfcc.claimDelegationRewards(maxEpochs, stakerID, {from: "0xAddress"})
For delegation in compound mode:
// check you have rewards to claim:
sfcc.calcDelegationCompoundRewards("0xAddress", stakerID, 0, maxEpochs) // returns: rewards amount, first claimed epoch, last claimed epoch
// claim rewards:
sfcc.claimDelegationCompoundRewards(maxEpochs, stakerID, {from: "0xAddress"})
For validator in non-compound mode:
YOUR_ID = sfcc.getStakerID("0xAddress") // if 0, then staker doesn't exist, or SFC functions aren't initialized correctly
// check you have rewards to claim:
sfcc.calcValidatorRewards(YOUR_ID, 0, maxEpochs) // returns: rewards amount, first claimed epoch, last claimed epoch
// claim rewards:
sfcc.claimValidatorRewards(maxEpochs, {from: "0xAddress"})
For validator in compound mode:
YOUR_ID = sfcc.getStakerID("0xAddress") // if 0, then staker doesn't exist, or SFC functions aren't initialized correctly
// check you have rewards to claim:
sfcc.calcValidatorCompoundRewards(YOUR_ID, 0, maxEpochs) // returns: rewards amount, first claimed epoch, last claimed epoch
// claim rewards:
sfcc.claimValidatorCompoundRewards(maxEpochs, {from: "0xAddress"})
- Delegation/validator must exist
- Delegation/validator isn't deactivated (i.e. didn't prepare to withdraw)
-
maxEpochs
>= 1