Skip to content
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

feat(StakeVault): add withdraw function and improve documentation #144

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

3esmit
Copy link
Collaborator

@3esmit 3esmit commented Oct 1, 2024

Description

Fixes #143

This commit introduces new functions for keeping track of the total amount staked and implements a function to check the available amount of tokens that can be withdrawn. Users are able to withdraw tokens that are not commited to stake by calling the withdraw functions. These changes enhance the overall usability and flexibility of the StakeVault contract.

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran pnpm adorno?
  • Ran pnpm verify?

This commit introduces new functions for keeping track of the total amount staked and implements a function to check the available amount of tokens that can be withdrawn. Users are able to withdraw tokens that are not commited to stake by calling the withdraw functions. These changes enhance the overall usability and flexibility of the StakeVault contract.
@3esmit 3esmit requested a review from 0x-r4bbit October 1, 2024 21:33
@3esmit 3esmit self-assigned this Oct 1, 2024
@3esmit 3esmit added the type: feature New feature or request label Oct 1, 2024
if (_token == STAKED_TOKEN) {
return STAKED_TOKEN.balanceOf(address(this)) - amountStaked;
}
return _token.balanceOf(address(this));
Copy link
Collaborator

Choose a reason for hiding this comment

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

In which case would we not want to get the amount from whatever STAKED_TOKEN is?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see.. i think this is for when possibly, accidentially funds where sent to the stakevault?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, and can also be used as a feature to StakeVault receive rewards from StakeManager.

@3esmit
Copy link
Collaborator Author

3esmit commented Oct 7, 2024

fixes #136
part of #137

*/
function withdraw(uint256 _amount) external onlyOwner {
_withdraw(_amount, payable(msg.sender));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just realized, there's actually very little point in having this here because this contract cannot receive any eth. There's no receive() or fallback implementation here. So we might as well drop this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(StakeVault): allow users to withdraw ether or tokens which are not commited to staking
2 participants