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: add script to upgrade Pool Voter #47

Merged
merged 8 commits into from
Aug 16, 2024

Conversation

oxoxDev
Copy link
Contributor

@oxoxDev oxoxDev commented Aug 2, 2024

No description provided.

*/
function unstakeToken(uint256 tokenId) external updateReward(msg.sender) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can keep both functions it'll be great. unstakeToken and unstakeAndWithdraw

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed here: 87ca53c

@@ -292,7 +292,8 @@ contract BaseLocker is
/// @dev Only possible if the lock has expired
function withdraw(uint256 _tokenId) public virtual nonReentrant {
require(
_isAuthorized(ownerOf(_tokenId), msg.sender, _tokenId),
_isAuthorized(ownerOf(_tokenId), msg.sender, _tokenId) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't have to modify the lockers now. It'll be a pain to upgrade the lockers as well.

It'll be a lot better to withdraw the tokens within the staking contract itself and send it over to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved here: 866d93e

votingPowerCombined.reset(msg.sender);

locker.safeTransferFrom(address(this), msg.sender, tokenId);
function unstakeAndWithdraw(uint256 tokenId) external {
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a nonRentrant hook just for safety

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed here: 87ca53c

tokenPower[tokenId] = 0;
votingPowerCombined.reset(msg.sender);

locker.safeTransferFrom(address(this), msg.sender, tokenId);
Copy link
Contributor

Choose a reason for hiding this comment

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

here if we sent the nft to the contract itself, we can withdraw the tokens and send it back to the user in one transaction itself without having to give special approvals.

consider adding a to arguement to the unstakeToken fn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed here: 87ca53c

);

// reset and burn voting power
_burn(msg.sender, tokenPower[tokenId]);
Copy link
Contributor

Choose a reason for hiding this comment

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

checks and balance. move this after the line 415

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deadshotryker could you please explain this, IMO this shouldn't be after line 415.

@deadshotryker deadshotryker merged commit 5bfbce7 into zerolend:main Aug 16, 2024
1 check failed
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