From 7935718dbfdb7c309973cff8996b387019bee9d8 Mon Sep 17 00:00:00 2001 From: lucasmt Date: Wed, 25 Sep 2024 17:49:36 -0500 Subject: [PATCH] Fixes to list insert functions --- src/RepoTokenList.sol | 4 +++- src/TermAuctionList.sol | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/RepoTokenList.sol b/src/RepoTokenList.sol index 391eb224..b22e4a87 100644 --- a/src/RepoTokenList.sol +++ b/src/RepoTokenList.sol @@ -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; } @@ -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 { @@ -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; } diff --git a/src/TermAuctionList.sol b/src/TermAuctionList.sol index 18ed8408..333af754 100644 --- a/src/TermAuctionList.sol +++ b/src/TermAuctionList.sol @@ -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; } @@ -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 { @@ -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; } @@ -375,4 +377,4 @@ library TermAuctionList { current = _getNext(listData, current); } } -} \ No newline at end of file +}