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

Pass 2 hints (prev and next) to SortedCDPs.insert #91

Closed
bingen opened this issue Nov 11, 2020 · 4 comments
Closed

Pass 2 hints (prev and next) to SortedCDPs.insert #91

bingen opened this issue Nov 11, 2020 · 4 comments
Assignees
Milestone

Comments

@bingen
Copy link
Collaborator

bingen commented Nov 11, 2020

Function insert in SortedCDPs uses 2 hints, but it’s called from BorrowerOperations and CDPManager with _prevId and _nextId being the same.
In particular, when _validInsertPosition is called, it’s always going to return false, except in the trivial case where the list is empty and the hint is zero.
It makes more sense that is called with different arguments for each hint for the call from openLoan (its signature needs to be changed too).

@danielattilasimon
Copy link
Collaborator

danielattilasimon commented Nov 11, 2020

The middleware will need updating around this piece:

const approxHint = await this.hintHelpers.getApproxHint(
collateralRatio.bigNumber,
numberOfTrials
);
const [hint] = await this.sortedCDPs.findInsertPosition(
collateralRatio.bigNumber,
price.bigNumber,
approxHint,
approxHint
);
return hint;

As you can see it's currently picking the first element of the return tuple of findInsertPosition as hint, but we could just as well take both.

@danielattilasimon
Copy link
Collaborator

I recommend making this change after #94 to avoid conflicts.

@RickGriff RickGriff added this to the Audit milestone Nov 13, 2020
@bingen bingen self-assigned this Jan 8, 2021
@bingen
Copy link
Collaborator Author

bingen commented Jan 14, 2021

Fixed in #228

@bingen bingen closed this as completed Jan 14, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version @liquity/lib-ethers-v1.0.0 🎉

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
Projects
None yet
Development

No branches or pull requests

3 participants