Skip to content

Commit

Permalink
Remove bucket depth constraint, add test for settle called with 0 buc…
Browse files Browse the repository at this point in the history
…kets (settle only with reserves)
  • Loading branch information
grandizzy committed Mar 1, 2023
1 parent 05826d6 commit e87949c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
5 changes: 0 additions & 5 deletions src/interfaces/pool/commons/IPoolErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ interface IPoolErrors {
*/
error InsufficientLiquidity();

/**
* @notice When settling pool debt the number of buckets to use should be greater than 0.
*/
error InvalidBucketDepth();

/**
* @notice When transferring LPs between indices, the new index must be a valid index.
*/
Expand Down
4 changes: 0 additions & 4 deletions src/libraries/external/Auctions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ library Auctions {
error CollateralRoundingNeededButNotPossible();
error InsufficientLiquidity();
error InsufficientCollateral();
error InvalidBucketDepth();
error InvalidAmount();
error NoAuction();
error NoReserves();
Expand Down Expand Up @@ -207,9 +206,6 @@ library Auctions {
uint256 collateralSettled_,
uint256 t0DebtSettled_
) {
// revert if no bucket to settle
if (params_.bucketDepth == 0 ) revert InvalidBucketDepth();

uint256 kickTime = auctions_.liquidations[params_.borrower].kickTime;
if (kickTime == 0) revert NoAuction();

Expand Down
6 changes: 0 additions & 6 deletions tests/forge/ERC20Pool/ERC20PoolInputValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
ERC20Pool(address(_pool)).removeCollateral(0, 1000);
}

function testValidateSettleInput() external tearDown {
// revert on zero amount
vm.expectRevert(IPoolErrors.InvalidBucketDepth.selector);
ERC20Pool(address(_pool)).settle(address(this), 0);
}

function testValidateTakeInput() external tearDown {
// revert on zero amount
vm.expectRevert(IPoolErrors.InvalidAmount.selector);
Expand Down
19 changes: 13 additions & 6 deletions tests/forge/ERC20Pool/ERC20PoolLiquidationsTake.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1576,22 +1576,29 @@ contract ERC20PoolLiquidationsTakeTest is ERC20HelperContract {
auctionPrice: 0,
timeRemaining: 0
});

// partial clears / debt settled - max buckets to use is 1, remaining will be taken from reserves
// partial clears / debt settled - max buckets to use is 0, settle only from reserves
_settle({
from: _lender,
borrower: _borrower2,
maxDepth: 1,
settledDebt: 2_923.975862386543877283 * 1e18
maxDepth: 0,
settledDebt: 834 * 1e18
});

_assertReserveAuction({
reserves: 0.989870342666661239 * 1e18,
reserves: 0.989870342666662235 * 1e18,
claimableReserves : 0,
claimableReservesRemaining: 0,
auctionPrice: 0,
timeRemaining: 0
});

// partial clears / debt settled with max buckets to use is 1
_settle({
from: _lender,
borrower: _borrower2,
maxDepth: 1,
settledDebt: 2_089.975862386543877283 * 1e18
});

_assertAuction(
AuctionParams({
borrower: _borrower2,
Expand Down
6 changes: 0 additions & 6 deletions tests/forge/ERC721Pool/ERC721PoolInputValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ contract ERC721PoolBorrowTest is ERC721HelperContract {
ERC721Pool(address(_pool)).removeCollateral(0, 1000);
}

function testValidateSettleInput() external tearDown {
// revert on zero amount
vm.expectRevert(IPoolErrors.InvalidBucketDepth.selector);
ERC721Pool(address(_pool)).settle(address(this), 0);
}

function testValidateTakeInput() external tearDown {
// revert on zero amount
vm.expectRevert(IPoolErrors.InvalidAmount.selector);
Expand Down

0 comments on commit e87949c

Please sign in to comment.