Skip to content

[wip] Same Token Staking + Improved Features#2

Open
DeFiFoFum wants to merge 9 commits into
feature/reflect-tokensfrom
feature/same-token-staking
Open

[wip] Same Token Staking + Improved Features#2
DeFiFoFum wants to merge 9 commits into
feature/reflect-tokensfrom
feature/same-token-staking

Conversation

@DeFiFoFum

@DeFiFoFum DeFiFoFum commented May 4, 2021

Copy link
Copy Markdown
Contributor

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 thread contracts/ApeRewardPool.sol Outdated
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
Copy Markdown
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
Copy Markdown
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.

Comment thread test/helpers/snapshot.js
console.log({ amount: amount.toString(), rewardDebt: rewardDebt.toString() });
}

async function getPoolSnapshot(rewardPoolContract) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Super cool!

@Apegurus Apegurus left a comment

Copy link
Copy Markdown
Contributor

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