From d736725d808b20e67c05d32c5cc0a5e788a54d48 Mon Sep 17 00:00:00 2001 From: Jem <0x0xjem@gmail.com> Date: Tue, 7 Jan 2025 17:05:54 +0400 Subject: [PATCH] CDAuctioneer: incorrect conditional when checking auction parameters. Fix tests. --- src/policies/CDAuctioneer.sol | 2 +- .../ConvertibleDepositAuctioneerTest.sol | 4 ++-- .../setAuctionParameters.t.sol | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/policies/CDAuctioneer.sol b/src/policies/CDAuctioneer.sol index c7646037..85a113a8 100644 --- a/src/policies/CDAuctioneer.sol +++ b/src/policies/CDAuctioneer.sol @@ -405,7 +405,7 @@ contract CDAuctioneer is IConvertibleDepositAuctioneer, Policy, RolesConsumer, R // Ensure that the minimum price is enforced // Otherwise, OHM will be converted at a price lower than the minimum - if (minPrice_ < _previousTick.price) { + if (minPrice_ > _previousTick.price) { _previousTick.price = minPrice_; } diff --git a/src/test/policies/ConvertibleDepositAuctioneer/ConvertibleDepositAuctioneerTest.sol b/src/test/policies/ConvertibleDepositAuctioneer/ConvertibleDepositAuctioneerTest.sol index 29ce9f9e..5a384f2b 100644 --- a/src/test/policies/ConvertibleDepositAuctioneer/ConvertibleDepositAuctioneerTest.sol +++ b/src/test/policies/ConvertibleDepositAuctioneer/ConvertibleDepositAuctioneerTest.sol @@ -118,8 +118,8 @@ contract ConvertibleDepositAuctioneerTest is Test { function _assertPreviousTick(uint256 capacity_, uint256 price_) internal { IConvertibleDepositAuctioneer.Tick memory tick = auctioneer.getPreviousTick(); - assertEq(tick.capacity, capacity_, "capacity"); - assertEq(tick.price, price_, "price"); + assertEq(tick.capacity, capacity_, "previous tick capacity"); + assertEq(tick.price, price_, "previous tick price"); } // ========== MODIFIERS ========== // diff --git a/src/test/policies/ConvertibleDepositAuctioneer/setAuctionParameters.t.sol b/src/test/policies/ConvertibleDepositAuctioneer/setAuctionParameters.t.sol index c4e88ce0..b0c5b4f5 100644 --- a/src/test/policies/ConvertibleDepositAuctioneer/setAuctionParameters.t.sol +++ b/src/test/policies/ConvertibleDepositAuctioneer/setAuctionParameters.t.sol @@ -51,12 +51,16 @@ contract ConvertibleDepositAuctioneerAuctionParametersTest is ConvertibleDeposit } function test_contractNotInitialized() public { + uint256 newTarget = 21e9; + uint256 newTickSize = 11e9; + uint256 newMinPrice = 14e18; + // Call function vm.prank(heart); - auctioneer.setAuctionParameters(100, 101, 102); + auctioneer.setAuctionParameters(newTarget, newTickSize, newMinPrice); // Assert state - _assertAuctionParameters(100, 101, 102, 0); + _assertAuctionParameters(newTarget, newTickSize, newMinPrice, 0); } function test_targetZero() public givenInitialized { @@ -70,7 +74,7 @@ contract ConvertibleDepositAuctioneerAuctionParametersTest is ConvertibleDeposit uint256 newTarget = 0; uint256 newTickSize = 11e9; - uint256 newMinPrice = 16e18; + uint256 newMinPrice = 14e18; // Expect event vm.expectEmit(true, true, true, true); @@ -131,7 +135,7 @@ contract ConvertibleDepositAuctioneerAuctionParametersTest is ConvertibleDeposit uint256 newTarget = 21e9; uint256 newTickSize = 11e9; - uint256 newMinPrice = 16e18; + uint256 newMinPrice = 14e18; // Expect event vm.expectEmit(true, true, true, true); @@ -160,7 +164,7 @@ contract ConvertibleDepositAuctioneerAuctionParametersTest is ConvertibleDeposit uint256 newTarget = 21e9; uint256 newTickSize = 11e9; - uint256 newMinPrice = 16e18; + uint256 newMinPrice = 14e18; // Expect event vm.expectEmit(true, true, true, true);