Skip to content

Commit

Permalink
CDAuctioneer: incorrect conditional when checking auction parameters.…
Browse files Browse the repository at this point in the history
… Fix tests.
  • Loading branch information
0xJem committed Jan 7, 2025
1 parent fa4b099 commit d736725
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/policies/CDAuctioneer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ========== //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d736725

Please sign in to comment.