Skip to content

Commit

Permalink
Merge pull request #46 from lucasmt/insert-fixes
Browse files Browse the repository at this point in the history
Fixes to the list insert functions
  • Loading branch information
aazhou1 authored Sep 26, 2024
2 parents b413039 + 7935718 commit b07fc46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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);
}
}
}
}

0 comments on commit b07fc46

Please sign in to comment.