-
Notifications
You must be signed in to change notification settings - Fork 321
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
Improve recovery from outdated hints in SortedTroves #600
Comments
Workaround for the current version is to pass |
… SortedTroves When trying to create a new Trove that has a lower ICR than the current lowest ICR (i.e. inserting into the tail of the list), `findInsertPosition()` returns `(addressOfLowestICRTrove, address(0))`. If we blindly pass these as hints to `openTrove()` but the transaction ends up pending for so long that the backend needs to look for a new insert position, we start the traversal in the wrong direction (from the wrong end of the list), and end up having to traverse over almost the entire list. Work around this by replacing the zero address with the other hint. Workaround for #600.
… SortedTroves When trying to create a new Trove that has a lower ICR than the current lowest ICR (i.e. inserting into the tail of the list), `findInsertPosition()` returns `(addressOfLowestICRTrove, address(0))`. If we blindly pass these as hints to `openTrove()` but the transaction ends up pending for so long that the backend needs to look for a new insert position, we start the traversal in the wrong direction (from the wrong end of the list), and end up having to traverse over almost the entire list. Work around this by replacing the zero address with the other hint. Workaround for #600.
We just had a user who had the lowest ICR trove in the system, trying to adjust his trove to go lower. The tx failed before broadcast - presumably because gas estimation didn't allow it. I believe this is the edge case DeFiSaver found - and I mistakenly thought the solution outlined above also covered it. The problem is that for the last trove in the list, the The DefiSaver fix was to check for this specific edge case: if the trove is last in the list, use the 2nd last trove's address as both hints. |
The current version of SortedTroves could be further improved for the case when hints become outdated because the NICR of the inserted Trove increases over time. This is a fairly common occurance due to the decay of the borrowing fee.
Let’s say we're trying to create a new Trove that has a lower ICR than the current lowest ICR (i.e. inserting into the tail of the list).
findInsertPosition()
returns(addressOfLowestICRTrove, address(0))
in this case. If we blindly pass these as hints toopenTrove()
(as we currently do in the middleware), but the transaction ends up pending for so long that we need to look for a new insert position, we start the traversal in the wrong direction (from the wrong end of the list), and end up having to traverse over almost the entire list.The text was updated successfully, but these errors were encountered: