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

Allow unstake passing a larger amount than available #487

Merged
merged 2 commits into from
Sep 22, 2021

Conversation

abarmat
Copy link
Contributor

@abarmat abarmat commented Jul 20, 2021

Description

When an indexer decides to unstake their stake completely there might be an opportunity to frontrun that operation through the stakeTo() function, making unstake to fail with stake under minimum tokens.

Solution

Allow unstake() to accept a larger amount than the currently staked tokens. The function will try to unstake the passed amount capped to the available stake.

@abarmat abarmat added the GIP label Jul 20, 2021
Copy link
Contributor

@davekaj davekaj left a comment

Choose a reason for hiding this comment

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

Looks good to me. Only thing I saw was the same thing Heiko mentioned in slack

@abarmat abarmat added the bug Something isn't working label Aug 9, 2021
@abarmat abarmat force-pushed the ariel/unstake-all-margin branch from 71957c3 to 89efcdc Compare September 22, 2021 12:44
@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #487 (89efcdc) into dev (834854a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #487   +/-   ##
=======================================
  Coverage   91.91%   91.91%           
=======================================
  Files          33       33           
  Lines        1658     1658           
  Branches      283      282    -1     
=======================================
  Hits         1524     1524           
  Misses        134      134           
Flag Coverage Δ
unittests 91.91% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
contracts/staking/Staking.sol 99.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 834854a...89efcdc. Read the comment docs.

@abarmat
Copy link
Contributor Author

abarmat commented Sep 22, 2021

@abarmat abarmat merged commit f34e90b into dev Sep 22, 2021
@abarmat abarmat deleted the ariel/unstake-all-margin branch September 22, 2021 14:10
abarmat added a commit that referenced this pull request Sep 28, 2021
- Update GNS implementation address
- Allow unstake passing a larger amount than available (#487)
- Revert when not enough precision to assign a delegation share
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audited bug Something isn't working GIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants