From 79aa4f6d7003c1baf81176854eb37cd3d02fe34b Mon Sep 17 00:00:00 2001 From: Daniel Simon Date: Thu, 29 Aug 2024 20:44:22 +0700 Subject: [PATCH] fix: batch managers shifted by one in `MultiTroveGetter` --- contracts/src/MultiTroveGetter.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/src/MultiTroveGetter.sol b/contracts/src/MultiTroveGetter.sol index dfff42be..e30d2b1b 100644 --- a/contracts/src/MultiTroveGetter.sol +++ b/contracts/src/MultiTroveGetter.sol @@ -126,18 +126,18 @@ contract MultiTroveGetter is IMultiTroveGetter { assert(address(sortedTroves) != address(0)); data = new DebtPerInterestRate[](_maxIterations); - currId = _startId; + currId = sortedTroves.getPrev(_startId); for (uint256 i = 0; i < _maxIterations; ++i) { - BatchId interestBatchManager; - - (, currId, interestBatchManager,) = sortedTroves.nodes(currId); if (currId == 0) break; + (, uint256 prevId, BatchId interestBatchManager,) = sortedTroves.nodes(currId); LatestTroveData memory trove = troveManager.getLatestTroveData(currId); data[i].interestBatchManager = BatchId.unwrap(interestBatchManager); data[i].interestRate = trove.annualInterestRate; data[i].debt = trove.entireDebt; + + currId = prevId; } } }