Skip to content

[wip] Same Token Staking + Improved Features #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: feature/reflect-tokens
Choose a base branch
from

Conversation

DeFiFoFum
Copy link
Contributor

@DeFiFoFum DeFiFoFum commented May 4, 2021

NOTE: Based on this update, rewards MUST be deposited through the deposit function or they won't be counted towards rewards. This is to account for same token staking/reflect fees.

  • Owner of the contract is now the user that created it from the factory. They can change the bonusEndBlock, emergencyWithdraw rewards, and skim stake and reward token fees
  • Added support for same token staking
  • Managing rewardsLeftToPay instead of totalRewardDebt to give a more robust way to find the availableRewards
  • Skim reflect rewards on reward tokens
  • When depositing rewards, there is an option to extend the bonusEndBlock which takes the current rewardPerBlock and finds how many blocks should be extended based on the deposit amount

DeFiFoFum added 4 commits May 4, 2021 12:09
- fixed logic for update reward block with reflect tokens
- allow pool creator to be the owner of the pool to change endblock and other features
@Apegurus Apegurus self-requested a review May 5, 2021 03:12
Comment on lines 320 to 323
if(isSameTokenPool()) {
// TODO: Is there a way we can calculate this easier?
// NOTE: If both tokens are reflect tokens then this is difficult
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have only one of these made available for single token stake pools?

Would:

return totalRewardTokenBalance().add(totalStakeTokenBalance()).sub(rewardBalance).sub(totalStaked);

Work if we do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh nice call. That's a solid approach.

console.log({ amount: amount.toString(), rewardDebt: rewardDebt.toString() });
}

async function getPoolSnapshot(rewardPoolContract) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool!

Copy link
Contributor

@Apegurus Apegurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding work! Looking good. Some tests are missing but we can also deploy this into testnet and take a deeper look

Just a small comment that might help out

DeFiFoFum added 5 commits May 6, 2021 13:52
- Add OZ reeentrancy guard to protect against withdraw/deposit attacks
- Calculate same token fee balance
- rename functions to balanceOfStakeToken and balanceOfRewardToken for better readability
@DeFiFoFum DeFiFoFum changed the title Same Token Staking + Improved Features [wip] Same Token Staking + Improved Features Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants