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

Fixes to the list insert functions #46

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/RepoTokenList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ library RepoTokenList {
// If the list is empty, set the new repoToken as the head
if (current == NULL_NODE) {
listData.head = repoToken;
listData.nodes[repoToken].next = NULL_NODE;
return;
}

Expand All @@ -399,7 +400,7 @@ library RepoTokenList {
uint256 maturityToInsert = getRepoTokenMaturity(repoToken);

// Insert repoToken before current if its maturity is less than or equal
if (maturityToInsert <= currentMaturity) {
if (maturityToInsert < currentMaturity) {
if (prev == NULL_NODE) {
listData.head = repoToken;
} else {
Expand All @@ -415,6 +416,7 @@ library RepoTokenList {
// If at the end of the list, insert repoToken after current
if (next == NULL_NODE) {
listData.nodes[current].next = repoToken;
listData.nodes[repoToken].next = NULL_NODE;
break;
}

Expand Down
6 changes: 4 additions & 2 deletions src/TermAuctionList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ library TermAuctionList {
// If the list is empty, set the new repoToken as the head
if (current == NULL_NODE) {
listData.head = offerId;
listData.nodes[offerId].next = NULL_NODE;
listData.offers[offerId] = pendingOffer;
return;
}
Expand All @@ -119,7 +120,7 @@ library TermAuctionList {
address auctionToInsert = address(pendingOffer.termAuction);

// Insert repoToken before current if its maturity is less than or equal
if (auctionToInsert <= currentAuction) {
if (auctionToInsert < currentAuction) {
if (prev == NULL_NODE) {
listData.head = offerId;
} else {
Expand All @@ -135,6 +136,7 @@ library TermAuctionList {
// If at the end of the list, insert repoToken after current
if (next == NULL_NODE) {
listData.nodes[current].next = offerId;
listData.nodes[offerId].next = NULL_NODE;
break;
}

Expand Down Expand Up @@ -375,4 +377,4 @@ library TermAuctionList {
current = _getNext(listData, current);
}
}
}
}
Loading