Skip to content

Commit

Permalink
Minor comment and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RickGriff committed Feb 14, 2024
1 parent 9fe10da commit 35397ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions contracts/src/BorrowerOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe
}

function adjustTroveInterestRate(uint _newAnnualInterestRate, address _upperHint, address _lowerHint) external {
// TODO: Delegation functionality
_requireValidAnnualInterestRate(_newAnnualInterestRate);
ITroveManager troveManagerCached = troveManager;
_requireTroveisActive(troveManagerCached, msg.sender);
Expand Down
11 changes: 5 additions & 6 deletions contracts/src/test/interestRateBasic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ contract InterestRateBasic is DevTestSetup {
assertEq(troveManager.getTroveAnnualInterestRate(C), 1e18);
}

// TODO: test adjusting interest rates correctly orders sorted list
function testAdjustTroveInterestRateInsertsToCorrectPositionInSortedList() public {
priceFeed.setPrice(2000e18);
openTroveNoHints100pctMaxFee(A, 2 ether, 2000e18, 1e17);
Expand All @@ -120,7 +119,7 @@ contract InterestRateBasic is DevTestSetup {
openTroveNoHints100pctMaxFee(D, 2 ether, 2000e18, 4e17);
openTroveNoHints100pctMaxFee(E, 2 ether, 2000e18, 5e17);

// Check initial sorted list order - expect [A:1%, B:2%, C:3%, D:4%, E:5%]
// Check initial sorted list order - expect [A:10%, B:02%, C:30%, D:40%, E:50%]
// A
assertEq(sortedTroves.getNext(A), ZERO_ADDRESS); // tail
assertEq(sortedTroves.getPrev(A), B);
Expand All @@ -137,17 +136,17 @@ contract InterestRateBasic is DevTestSetup {
assertEq(sortedTroves.getNext(E), D);
assertEq(sortedTroves.getPrev(E), ZERO_ADDRESS); // head

// C sets rate to 0%, moves to tail - expect [C:0%, A:1%, B:2%, D:4%, E:5%]
// C sets rate to 0%, moves to tail - expect [C:0%, A:10%, B:20%, D:40%, E:50%]
changeInterestRateNoHints(C, 0);
assertEq(sortedTroves.getNext(C), ZERO_ADDRESS);
assertEq(sortedTroves.getPrev(C), A);

// D sets rate to 7%, moves to head - expect [C:0%, A:1%, B:2%, E:5%, D:7%]
// D sets rate to 7%, moves to head - expect [C:0%, A:10%, B:20%, E:50%, D:70%]
changeInterestRateNoHints(D, 7e17);
assertEq(sortedTroves.getNext(D), E);
assertEq(sortedTroves.getPrev(D), ZERO_ADDRESS);

// A sets rate to 6%, moves up 2 positions - expect [C:0%, B:2%, E:5%, A:6%, D:7%]
// A sets rate to 6%, moves up 2 positions - expect [C:0%, B:20%, E:50%, A:60%, D:70%]
changeInterestRateNoHints(A, 6e17);
assertEq(sortedTroves.getNext(A), E);
assertEq(sortedTroves.getPrev(A), D);
Expand Down Expand Up @@ -192,7 +191,7 @@ contract InterestRateBasic is DevTestSetup {
// Adjust E's coll + debt
adjustTrove100pctMaxFee(E, 10 ether, 5000e18, true, true);

// Check C's neighbors unchanged
// Check E's neighbors unchanged
assertEq(sortedTroves.getNext(E), D);
assertEq(sortedTroves.getPrev(E), ZERO_ADDRESS); // head
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/test/TroveManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ contract("TroveManager", async (accounts) => {
// TODO: revisit the relevance of this test since it relies on liquidateTroves(), which now no longer works due to ordering by interest rate.
// Can we achieve / test the same thing using another liquidation function?

it.skip("batchLiquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => {
it("batchLiquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => {
// A, B, C, D, E open troves
await openTrove({ ICR: toBN(dec(300, 16)), extraParams: { from: C } });
await openTrove({ ICR: toBN(dec(364, 16)), extraParams: { from: D } });
Expand Down Expand Up @@ -1277,7 +1277,7 @@ contract("TroveManager", async (accounts) => {
assert.isTrue(ICR_C.gt(TCR));

// Attempt to liquidate B and C, which skips C in the liquidation since it is immune
const liqTxBC = await troveManager.liquidateTroves(2);
const liqTxBC = await troveManager.batchLiquidateTroves([B,C]);
assert.isTrue(liqTxBC.receipt.status);
assert.isFalse(await sortedTroves.contains(B));
assert.isTrue(await sortedTroves.contains(C));
Expand All @@ -1286,8 +1286,8 @@ contract("TroveManager", async (accounts) => {

// // All remaining troves D and E repay a little debt, applying their pending rewards
assert.isTrue((await sortedTroves.getSize()).eq(toBN("3")));
await borrowerOperations.repayBold(dec(1, 18), D, D, { from: D });
await borrowerOperations.repayBold(dec(1, 18), E, E, { from: E });
await borrowerOperations.repayBold(dec(1, 18), { from: D });
await borrowerOperations.repayBold(dec(1, 18), { from: E });

// Check C is the only trove that has pending rewards
assert.isTrue(await troveManager.hasPendingRewards(C));
Expand Down

0 comments on commit 35397ec

Please sign in to comment.