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

Explain liquidation status better post-withdrawing rewards #1751

Merged
merged 4 commits into from
Jul 20, 2020

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Jul 17, 2020

Once a liquidation has expired and the liquidator has withdrawn rewards, the liquidation will be deleted because there are no rewards for other parties remaining. However, the liquidator bot incorrectly translates the ensuing state (state gets reset to 0 once a liquidation is deleted) as "Dispute Failed".

The subtlety here is that after calling withdrawLiquidation() on EITHER a failed-disputed-liquidation OR an expired-liquidation, the state will get set to 0:

See this incorrect log message's "liquidation status" value for example:
Screen Shot 2020-07-17 at 08 50 59

Corrected log message here:
Screen Shot 2020-07-17 at 11 12 25

Signed-off-by: Nick Pai npai.nyc@gmail.com

Signed-off-by: Nick Pai <npai.nyc@gmail.com>
@coveralls
Copy link

coveralls commented Jul 17, 2020

Coverage Status

Coverage remained the same at 92.73% when pulling f1bbc7f on npai/liquidator-messaging-fix into 2333de6 on master.

Copy link
Member

@chrismaree chrismaree left a comment

Choose a reason for hiding this comment

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

Great catch & fix! Modifying this scruct does effects anything else as this specific implementation is the only place we use PostWithdrawLiquidationRewardsStatusTranslations right?

As an aside, it looks like the output in the slack message has larger spaces between line items. This is due to my most recent PR that updated the slack transport and how is spreads objects. In this context I'm not a huge fan of this. what do you think?

@nicholaspai
Copy link
Member Author

Great catch & fix! Modifying this scruct does effects anything else as this specific implementation is the only place we use PostWithdrawLiquidationRewardsStatusTranslations right?

As an aside, it looks like the output in the slack message has larger spaces between line items. This is due to my most recent PR that updated the slack transport and how is spreads objects. In this context I'm not a huge fan of this. what do you think?

I also don't like the large spaces between items, the entire message is too spread out now and takes up too much screen space.

Signed-off-by: Nick Pai <npai.nyc@gmail.com>
@nicholaspai
Copy link
Member Author

Made a small change to this PR: I removed the post-withdraw messaging for Liquidation status == 1 because this is impossible. After the liquidator/sponsor/disputer successfully calls withdrawLiquidation() the LiquidationStatus can ONLY be 0 or 3. If the Dispute failed or the liquidation expired without dispute (i.e. status 4 and 1 respectively), then the Liquidation will get deleted and the status will go to 0. If the Dispute succeeded (i.e. status 3), then it can stay at 3. If the Liquidation is pending dispute (i.e. status 2), then withdrawLiquidation() will fail.

For reference:

// States for an EMP's Liquidation to be in.
const LiquidationStatesEnum = {
  UNINITIALIZED: "0",
  PRE_DISPUTE: "1",
  PENDING_DISPUTE: "2",
  DISPUTE_SUCCEEDED: "3",
  DISPUTE_FAILED: "4"
};

// Maps the `liquidationStatus` property in the `LiquidationWithdrawn` event to human readable statuses.
// Note that these are status translations AFTER a withdrawLiquidation method is called
const PostWithdrawLiquidationRewardsStatusTranslations = {
  "0": "Liquidation deleted; All rewards have been withdrawn",
  "3": "Dispute succeeded; Not all rewards have been withdrawn"
  // @dev: Post `withdrawLiquidation()`, the status cannot be "2:PendingDispute", "1:PreDispute" or "4:DisputeFailed"
  // @dev: If a liquidation has expired (i.e. is pre-dispute) or a dispute has failed, then the first withdrawLiquidation() call will delete the liquidation
  // and reset its state to 0.
};

Copy link
Member

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM!

@nicholaspai nicholaspai merged commit 4abe2d9 into master Jul 20, 2020
@nicholaspai nicholaspai deleted the npai/liquidator-messaging-fix branch July 20, 2020 14:30
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.

4 participants