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

fix: work around huge gas cost when reducing ICR of bottom Trove #663

Merged
merged 2 commits into from
Aug 11, 2021

Conversation

danielattilasimon
Copy link
Collaborator

@danielattilasimon danielattilasimon commented Aug 2, 2021

The problem:

[...] for the last trove in the list, the addressOfLowestICRTrove is their own address - and the reinsertion first removes it before the insert. The system can't find it in the list, so starts at the opposite end, and runs out of gas.

DefiSaver's original workaround:

[...] check for this specific edge case: if the trove is last in the list, use the 2nd last trove's address as both hints.

This implements a generalized version of that workaround:

  • In either of the hints is the user's own Trove, "jump over" it and replace it with the next/prev Trove.
  • If either of the hints is address(0), replace it with the other hint.

Fixes #659.

@danielattilasimon danielattilasimon marked this pull request as ready for review August 4, 2021 03:06
Copy link
Contributor

@edmulraney edmulraney left a comment

Choose a reason for hiding this comment

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

@danielattilasimon danielattilasimon merged commit c50e17d into main Aug 11, 2021
@danielattilasimon danielattilasimon deleted the hints-workaround branch August 11, 2021 10:52
@github-actions
Copy link

🎉 This PR is included in version @liquity/lib-ethers-v3.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement workaround for SortedTroves edge case
2 participants