For all those who want to learn about staking, here is a quick write-up on how @OnChainMonsters staking works.
Their Medium post says, "Claiming of all MonsterDough ends Feb 01, 2022, 00:00:00 (GMT).", but that seems to be driving some confusion.
Let’s clear things up!
Here is `stakeByIds`. This function takes an array of token IDs.
The first thing it does is require this wallet can never have more than 10 monsters staked at one time.
It then loops through each token id and for each:
Transfers the token to the staking contract.
Adds the token to `stakerToTokenIds`.
Keeps track of the timestamp of staking time (this is used to calculate rewards).
Keeps track of the original owner for the token id.
Now your tokens are staked.
Up next, we have `unstakeAll`.
This function loops through and finds all the staked token ids for the caller.
For each token id the loop:
Transfers the token back to the original owner.
Calculates the `reward` for that specific token id and adds that reward to the total `reward` for all tokens being unstaked.
Calls `removeTokenIdFromStaker` (a helper function to clean up some data)
Resets `tokenIdToStaker` for that token to null.
Finally, after it loops through all the token IDs, it calls `_mint` and sends the $OCMD to the users. This is what is used to mint monsters 2000-10,000.
Quickly to `unstakeByIds`.
This does the exact same thing as `unstakeAll`, but instead of unstaking all the wallet’s tokens it just unstakes the specific tokens sent to the function.
Here is `claimByTokenId`. This is one of the functions that use the Feb 1st `CLAIM_END_TIME`.
It looks like this function can be used to claim your tokens for a specific staked token id.
So yes, this is no longer callable, BUT it looks like you can still call `unstakeByIds`/`unstakeAll` which will still allow you to “claim” your $OCMD.
It’s unclear if this was intentional by the devs or if this was an oversight.
Quickly now to `claimAll`.
It essentially does the same thing as `claimByTokenId`, but claims all rewards for all token ids instead of one individual token id.
This is the other function that uses the Feb 1st `CLAIM_END_TIME` and is no longer callable.
There are more functions in this contract that are helpful for seeing claim data, etc, but we’re going to skip reviewing those for now.
The main focus is to highlight the staking/claiming features and to clear up any confusion around their Medium post.
Thanks for reading!
If you liked this write-up and want to read more of these, please give us a follow on Twitter @BurnableLabs!
If you want to get these write-ups in your inbox, subscribe to our Substack!